So I wanted to setup a Windows 2003 Development virtual machine instance using VirtualBox on my notebook and then have the ability to get to that server from the network. Well it seems that VirtualBox is not real intuitive about handling this setup. Seems that the VirtualBox Guest NAT only does that; NAT’s the outbound traffic from the VM via the Host network adapter and does not allow any inbound packets (not stateful NAT requests) to get back to the VM’s NIC.
So after much toiling around on the VirtualBox forums I found the answer, you can setup a port forward on the host machine to send the particular port traffic to the VM NIC. This is, for some odd reason I must say, is not done via the VirtualBox GUI but via the commandline tool ‘C:\Program Files\innotek VirtualBox\VBoxManage.exe’.
So let’s say you have a VM instance named ‘Win2003Dev’ and you want to send Subversion (port 3690) traffic to/from that VM you would perform this:
- Close VirtualBox (this requires lock write to the VirtualBox.XML file), if running
- Open up a command line console (if using Vista you should use Start -> cmd -> CTRL+SHIFT+ENTER)
- Enter these three lines (one at a time, doh!):
123VBoxManage setextradata "Win2003Dev" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/svn/Protocol" TCPVBoxManage setextradata "Win2003Dev" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/svn/GuestPort" 3690VBoxManage setextradata <span class="str">"Win2003Dev" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/svn/HostPort" 3690</span>
- Note: The ‘svn’ I used in the lines is just something I picked, it seems you can use ‘hot-potato’ if you like. I thought something logical would make most sense.