set up port forwarding for guest linux server inside virtualbox on windows host

mostly for httpd and sshd, under dos:

VBoxManage setextradata "GuestName”  “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol” TCP
VBoxManage setextradata “GuestName”  “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort” 80
VBoxManage setextradata “GuestName”  “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort”  8880

and

VBoxManage setextradata "GuestName”   “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol” TCP
VBoxManage setextradata “GuestName”   “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort” 22
VBoxManage setextradata “GuestName”   “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort” 22

发现3.2.4里头vboxmanage已经不用setextradata来设置Port Forwarding了,而是改成更简洁易懂的:

VBoxManage modifyvm “Ubuntu” –natpf1 “guestssh,tcp,,2222,,22”

New version of VirtualBox is getting easier just use port forwarding under the “setting-network”. However, sometime it’s just weird that no matter how you tweak the host machine ports Putty ssh won’t get through. And easier way is to use the “Bridged Adaptor” instead of “NAT”. Using this MAC address to set up HWADDR in ifcfg-eth0: vi /etc/sysconfig/network-scripts/ifcfg-eth0; service sshd start; service network restart, if you got error: Bringing up interface eth0:  Device eth0 does not seem to be present,delaying initialization.                    [FAILED] This means the eth0, use ifconfig -a to know actually which ethX you should bring up and edit the ifcfg-eth0 to replace the eth0.

One thought on “set up port forwarding for guest linux server inside virtualbox on windows host”

  1. shrinking a dynamic virtualbox disk image
    http://www.thelinuxdaily.com/2010/02/shrinking-a-dynamic-virtualbox-disk-image/
    namely for the case of fedora guest under win7 host:
    ;under fedora
    sudo yum install zerofree
    sudo vi /etc/inittab
    ;change 3 or 5 to 2, reboot, and remount file system readonly
    mount -n -o remount,ro -t ext4 /dev/mapper/….. /
    zerofree /dev/mapper/…..
    ;reboot
    ;under win7, go to virtualbox directory
    VBoxManage modifyhd –compact /path/to/virtualboximage.vdi
    ;reboot and under fedora change inittab back to 3 or 5, reboot again, you done.

Comments are closed.