Nat – VirtualBox – Static Guest, accessible from host

configurationnat;virtualbox

I'm using VirtualBox trying to set up Windows as my dev environment, but an Ubuntu VM as my "virtual server".

So, Windows 7 is my host OS on my laptop. My guest OS is Ubuntu, which will run my LAMP setup. I take my laptop to friends places and my girlfriends place. Sometimes I use my ethernet adapter, sometimes the wireless – so I use different networks and different adapters and am trying to keep my configuration independant if this is possible.

I'd like the guest to have a static IP so I can set my hosts file in Windows to point to my Ubuntu "virtual server".

How should I do this?

I have managed to set up a static IP address in Ubuntu using NAT in VirtualBox, but of course I can't access anything from Windows – I need to be able to visit 10.0.2.15 in my broswer, but the virtual machine's hidden behind NAT …

Any ideas? Can you point me in the right direction on how this should be configured?

Thanks in advance!

Best Answer

Give the machine two interfaces -- a NAT interface for communicating with the outside world, and a host-only interface for communicating with your Windows host. This can have a static address, and you can point any Windows-side tools at it.

Your default route should be out the NAT interface.