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.