2008年3月2日 星期日

Virtualbox 作 Port Forwarding

  • An example of how to set up incoming NAT connections to a ssh server on the guest requires the following three commands:
    VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
    VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
    VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222

    The name guestssh is an arbitrary one chosen for this particular forwarding configuration. With that configuration in place, all TCP connections to port 2222 on the host will be forwarded to port 22 on the guest. Protocol can be either of TCP or UDP (these are case insensitive). To remove a mapping again, use the same commands, but leaving out the values (in this case TCP, 22 and 2222).

    • It is not possible to configure incoming NAT connections while the VM is running. However you can change the settings for a VM which is currently saved (or powered off at a snapshot).
  • 將 Host machine 的 8080 port 轉到 Guest machine 的 80 port:(假設 Guest machine 的名稱為 debian)
    # VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/Protocol" TCP
    # VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/GuestPort" 80
    # VBoxManage setextradata "Debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/HostPort" 8080

    設定後,請重新開啟 VirtualBox 軟體。這樣別人就可以從 http://127.0.0.1:8080/ 來瀏覽 Debian 的網頁伺服器了。

讓 Firefox 不要使用 Alt-<key> 的選單快速鍵..

1. Open about:config
2. filter to ui.key.generalaccesskey
3. Change value to 18 (default -1)
4. Restart browser