I’ve been using using VirtualBox for years to run dev boxes, and test OS’s.
Something that drives me mad is the fact that it doesn’t have a mode like VM Ware, that combines NAT for it’s connections to the outside world, along with a local IP for connecting to from the host machine.
I’ve been meaning to solve this problem for ages, as if causes me no end of annoyance when moving around from place-to-place with a laptop – having to change what your VM is connected to becomes a real pain. At home/work you can just used DHCP, and let your trusted gateway provide an IP – but if you are in an untrusted location, you needed to change this to host only.
Thus, the solution seemed to be two network adapters.
Under settings for the VM in question, go to network and enable two adapters. Make one NAT, and the other host-only. Make sure under the settings for VirtaulBox that you enable the host only network DHCP.
Then edit /etc/network/interfaces file on your VM as such:
auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet dhcp
Make sure your restart your networking with /etc/init.d/networking restart
And that should do it – you can now move your machine across any network, and it’s connected locally to the host on a fixed DHCP assigned IP, and it can also connect out via NAT on any network.