Need LAN and Internet access

Discussions related to using VirtualBox on Windows hosts.
Post Reply
JohnB352
Posts: 7
Joined: 5. Jan 2011, 03:02
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Server 2008, Windows 7

Need LAN and Internet access

Post by JohnB352 »

I'm fairly new to VirtualBox.
The guest OS's are Server 2008. If I set the network configuration in vbox to Host-Only Adapter, the 2 servers can communicate with each other, no problem. But, no internet access.

If I then set the Network Settings to NAT, they both have access to the internet, but not to each other. When it's set to Network, they both get the DHCP address of 10.0.2.15
So it makes sense why they can't ping each other - same IP address. If I then change them both to static, with the same IP settings, gateway, subnet mask, DNS, - but different IP addresses - 10.0.2.15, 10.0.2.16 - they can't ping each other. Which makes no sense.

Is it possible to have network access between guests AND have internet access for both?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Need LAN and Internet access

Post by Perryg »

Use Bridged if there is a router in the network or if not then use host-only as the first adapter (allows local access) and add a second adapter set to NAT (allows Internet access) in each guest.
JohnB352
Posts: 7
Joined: 5. Jan 2011, 03:02
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Server 2008, Windows 7

Re: Need LAN and Internet access

Post by JohnB352 »

Perryg wrote:Use Bridged if there is a router in the network or if not then use host-only as the first adapter (allows local access) and add a second adapter set to NAT (allows Internet access) in each guest.
Ok, that'll work. I really didn't want it on the same subnet, but it isn't a big deal. Thanks.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Need LAN and Internet access

Post by Perryg »

Then do what I suggested if you don't have a router. It works well.
Adapter 1 Host-only
Adapter 2 NAT
mschwartz
Posts: 92
Joined: 18. Oct 2010, 21:01
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: ubuntu

Re: Need LAN and Internet access

Post by mschwartz »

I wrote up a really long and detailed post about how to set up virtualbox guest with 1,2, or 3 adapters, but I can't find it. I wish it got stickied or that it would show up in my posts in my control panel.

Anyhow, you use 1 adapter as NAT if all you want is internet access.

You use 2 adapters, one as host only and one as NAT if you have a laptop situation and you want to be able to browse your guest from your host OS, even if you take your laptop to starbucks. At starbucks or at home, your NAT connection will provide internet access for the guest.

You use 3 adapters, one as host only, one as NAT, and one as bridged if you have a laptop solution like above, but when you're at home and on a second computer you want to browse your guest from.

Example using 2 adapters:
Guest uses NAT on adapter 1 for internet access.

Guest has a static IP on adapter 2 which is host only. The static IP (at least for me) is in the 192.168.56.x range where x > 1 and x < 100. On my windows host, I edit my /etc/hosts file and add an entry for 192.168.56.x so I can access the guest by name. My host has 192.168.56.1 assigned automagically by virtualbox.

Since the guest has a static IP, /etc/hosts is set up, and the interface is host only, accessing the guest from the host works if there is no internet, if you are at starbucks, at home, etc.

Example using 3 adapters:
Guest uses NAT on adapter 1 for Internet access.

Guest has a static IP on adapter 2 per above. This lets you do the starbucks thing and access the guest.

Guest has a static IP on adapter 3, which is bridged. The static IP is for your home (or work) LAN. My wifi router assigns DHCP addresses of 192.168.1.x where x > 99. So I choose one where x < 100.

A second (or third, etc.) system on your LAN can now access your guest via the 192.168.1.x IP.

NOTES:

1) How you set up the interfaces varies with the guest OS. For Ubuntu, I edit /etc/network/interfaces and configure the non-NAT interfaces statically.

2) If your LAN is Wifi, make sure you choose the wireless adapter type in virtualbox when you configure the adapter or it won't work.

3) The only default route (gateway) you need is for the NAT interface. All traffic to 192.168.1.x will be routed to your LAN. All traffic to 192.168.56.x will be routed to your host only network. This is what netmasks are for!

4) Use ping and traceroute to test it all out.
Post Reply