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

This is for discussing general topics about how to use VirtualBox.
Post Reply
Aren Cambre
Posts: 17
Joined: 20. Sep 2010, 18:23
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows 7

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

Post 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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

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

Post 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.
Aren Cambre
Posts: 17
Joined: 20. Sep 2010, 18:23
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows 7

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

Post 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.
Aren Cambre
Posts: 17
Joined: 20. Sep 2010, 18:23
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows 7

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

Post by Aren Cambre »

By the way, will the IP address of the host-only adapter stay relatively static on the guest?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

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

Post 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.
Post Reply