Page 1 of 1

Can access internet AND host can talk to it AND fixed IP

Posted: 20. Dec 2011, 05:38
by Aren Cambre
I have a Ubuntu guest running on my Windows 7 host. Its sole purpose is to run Postgres in a special sandbox.

I need for the guest to be able to talk to the internet. I also need the guest's Postgres to be available to apps running on the host.

The only way I've found to do this feels like a workaround: Put the guests's network adapter in bridged mode. This presents a few problems:
  • The IP can change, such as if I put the host machine to sleep for a day.
  • Some networks, like my corporate network, won't assign an IP to the guest OS.
  • The guest is accessible to other machines on the local network. I'd rather it be hidden.
Is there a solution that allows all of:
  • Fixed IP.
  • Internet access for guest
  • Accessible from host
What are my options?

On my home network, I could do static DHCP based on the guest OS's MAC. I could also prevent its DHCP from assigning a particular IP. I am running DD-WRT on the home router.

The documentation doesn't reveal a solution, although I'm not sure it excludes a workaround? I haven't found conclusive guidance on these forums, although I may not be searching correctly.

Re: Can access internet AND host can talk to it AND fixed IP

Posted: 20. Dec 2011, 15:57
by Perryg
Adapter 1 set to host-only and adapter 2 set to NAT.
This sets up the host and guest for communication and the NAT will allow the guest Internet access.

Re: Can access internet AND host can talk to it AND fixed IP

Posted: 21. Dec 2011, 04:40
by Aren Cambre
Ah, thanks! That did it.

I did try this before, but think where I went wrong was I was trying to access the guest using the IP address of "Ethernet adapter VirtualBox Host-Only Network" on the host, when in fact I need to use the IP address reported by the host-only adapter on the guest.

Re: Can access internet AND host can talk to it AND fixed IP

Posted: 21. Dec 2011, 04:40
by Aren Cambre
By the way, will the IP address of the host-only adapter stay relatively static on the guest?

Re: Can access internet AND host can talk to it AND fixed IP

Posted: 21. Dec 2011, 04:51
by Perryg
As long as you have the one guest. You can however make that address static to the guest as long as it is in the same range and you configure it properly.