Host-Only guest can't reach the net... - Solved

Discussions about using Windows guests in VirtualBox.
markfilipak2
Posts: 173
Joined: 15. Jul 2012, 18:23
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Linux Mint 18
Location: Ohio

Host-Only guest can't reach the net... - Solved

Post by markfilipak2 »

...Well, it does reach the net for DNS, but it can't ping (or http). I think I've tried everything but you may see something. What am I doing wrong?

Note: NAT worked, but I'd like to use Host-Only for various reasons.

My Current Network:
The Wi-Fi (192.168.1.100) has Internet Connection Sharing enabled for the VirtualBox Host-Only Network. I believe that it turns the host into the Host-Only network's Gateway. It works for DNS but not for data packets. I have all the well-known ports and protocols enabled in the Internet Connection Sharing, "Advanced Settings" dialog. I have set up (real) machines for such (real) interior networks in the past and it always worked. But not this time.

Guest's IP: 192.168.56.102/24
Guest's Gateway: 192.168.56.101
Guest's DHCP server: 192.168.56.100 <- set automagically?
Guest's DNS server: 192.168.56.101
Guest >ping 192.168.56.102 ...succeeds (<1ms)
Guest >ping 192.168.56.101 ...succeeds (1ms)
Guest >ping 192.168.56.100 ...fails
Guest >ping 192.168.1.100 ...succeeds (1ms)
Guest >ping 192.168.1.1 ...succeeds (2ms)
Guest >ping yahoo.com ...fails but DNS succeeds

Host's Host-Only IP: 192.168.56.101/24
Host's Host-Only Gateway: 192.168.1.100
Host's Host-Only DHCP server: 192.168.56.100 <- set automagically?
Host's Host-Only DNS server: 192.168.1.100
Host's Wi-Fi IP: 192.168.1.100/24
Host's Wi-Fi Gateway: 192.168.1.1
Host's Wi-Fi DHCP server: 192.168.1.1
Host's Wi-Fi DNS server: 192.168.1.1
Host >ping 192.168.1.1 ...succeeds (1ms)
Host >ping 192.168.1.100 ...succeeds (<1ms)
Host >ping 192.168.56.100 ...fails
Host >ping 192.168.56.101 ...succeeds (<1ms)
Host >ping 192.168.56.102 ...succeeds (<1ms)

Observations:
1 - 192.168.56.100 appears to be a DHCP server that just... appears! It does not ping.
2 - The first guest ping to yahoo.com fails completely but I can see what I assume to be DNS caching in the various activity lights. It goes all the way out to the Wi-Fi Gateway (and presumably out to the router and from there to the ISP's DNS server). Then, the second ping to yahoo.com, while also failing, shows the DNS which, due to caching, makes it only to the Host-Only DNS server where it is answered (the IP is 209.191.122.70). It's as though the 'reach' to Yahoo is just taking too long. I tried increasing the ping timeout all the way to 20 seconds but that didn't make a difference.
3 - Network discovery of workgroups, shares, etc. (i.e., My Network Places) is very fast in the guest. That is, the guest discovers the host's shares and printers almost immediately. However, in the host, network discovery of the guest is very, very slow, often taking 20 seconds.
4 - It sure would be nice if the virtual routers supported an HTTP console like a real router does.

Assumed DHCP & pools:
192.168.1.1 < Gateway Router < 65.185...
192.168.1.[100-199] < Wi-Fi < 192.168.1.1
192.168.56.[101-???] < Host-Only < 192.168.1.100

Comments? Help? Thanks in advance - Mark.
Last edited by markfilipak2 on 3. Aug 2012, 00:27, edited 2 times in total.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Host-Only guest can't reach the net...

Post by Perryg »

Host-only can not talk to the outside world.
Host-only networking is another networking mode that was added with version 2.2 of VirtualBox. It can be thought of as a hybrid between the bridged and internal networking modes: as with bridged networking, the virtual machines can talk to each other and the host as if they were connected through a physical ethernet switch. Similarly, as with internal networking however, a physical networking interface need not be present, and the virtual machines cannot talk to the world outside the host since they are not connected to a physical networking interface.
markfilipak2
Posts: 173
Joined: 15. Jul 2012, 18:23
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Linux Mint 18
Location: Ohio

Re: Host-Only guest can't reach the net...

Post by markfilipak2 »

This is embarrassing. I could have sworn that I read that, in addition to allowing the host & guest to share, Host-Only would also allow both of them to access the net by enabling the host's Internet Connection Sharing. It DID work, but only for DNS. Why it didn't work for data packets is a mystery. Oh well. I guess I read it in one of those misinforming forum posts found via Google.
ASeales
Posts: 2
Joined: 27. Jul 2012, 17:11

Re: Host-Only guest can't reach the net... - Solved

Post by ASeales »

I'm not sure why the docs say this because it's not true. I'm using a Linux host and a Windows 7 guest with host-only adapter, and the Windows 7 guest can access the outside world. The outside world cannot access my guest, but my host can.

You need to configure your host to use internet connection sharing, as you correctly guessed.

I also had to configure my guest a bit by manually adding a default route to the routing table, manually add in a DNS server to the network interface, and adjust the Windows firewall to allow my host to connect to it.
BillG
Volunteer
Posts: 5100
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Host-Only guest can't reach the net... - Solved

Post by BillG »

There is nothing special about the host only interface. It is just an interface in the host which a virtual machine can connect to. It behaves much like the Microsoft Loopback Adapter in Windows. Virtual machines connected to host only are in the same network as each other and also the host. By default the guests can only see each other and the host, but you can certainly route this network to any other network through the host. If you only want Internet access for the guests, ICS on the host will do fine.
Bill
markfilipak2
Posts: 173
Joined: 15. Jul 2012, 18:23
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Linux Mint 18
Location: Ohio

Re: Host-Only guest can't reach the net... - Solved

Post by markfilipak2 »

Thanks for your reply. I use the Microsoft loopback on occasions when I want to snoop the net. My impression of Host-Only is loopback with NAT. I couldn't figure out why I couldn't get it to work.
ASeales wrote:I also had to configure my guest a bit by manually adding a default route to the routing table,
What default route was needed? Where? Host-Only is not a router, so I don't know to what route you're referring. Can you illuminate further?
ASeales wrote:manually add in a DNS server to the network interface,
I just put my exterior Wi-Fi router's IP (192.168.1.1) as the DNS server... I think I did that... so to what DNS server do you refer?
ASeales wrote:and adjust the Windows firewall to allow my host to connect to it.
I think that's not needed if the exterior router does DNS. (I don't like to punch holes in my firewall.)

Comments?

Thanks - Mark.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Host-Only guest can't reach the net... - Solved

Post by mpack »

markfilipak wrote:My impression of Host-Only is loopback with NAT.
I don't know what would give you that impression. Host-only is an Ethernet network, so NAT doesn't apply. Though as Bill says, ICS could provide a conduit for internet access.
markfilipak2
Posts: 173
Joined: 15. Jul 2012, 18:23
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Linux Mint 18
Location: Ohio

Re: Host-Only guest can't reach the net... - Solved

Post by markfilipak2 »

Thank you mpack. I didn't know that Host-Only is a link-layer switch. That's good information and may help me figure out why my original set up (see initial post in this thread) didn't work. The first time I was trying out Host-Only I thought I saw IPs like 10.0.2.1 but now I realize I'm confusing Host-Only with NAT. Sorry. This still leaves me with the question why my original setup worked for DNS but not for packets.

I'm going to do more experimentation. I may be revising the " - Solved" suffix I added to the subject. Ciao - Mark.
ASeales
Posts: 2
Joined: 27. Jul 2012, 17:11

Re: Host-Only guest can't reach the net... - Solved

Post by ASeales »

markfilipak wrote:
ASeales wrote:I also had to configure my guest a bit by manually adding a default route to the routing table,
What default route was needed? Where? Host-Only is not a router, so I don't know to what route you're referring.
In my guest OS(Windows 7) the default route was missing. Specifically, I had to run

Code: Select all

route -p add 0.0.0.0 mask 0.0.0.0 192.168.56.1
192.168.56.1 is the address of the virtual interface in my guest os, so yours will be different. This is basically telling Windows how to access the internet. It's possible you don't need to do this if your DNS was working, but I did. You can tell if you need to. If you type

Code: Select all

route print
There should be a similar line.
markfilipak wrote:
ASeales wrote:manually add in a DNS server to the network interface,
I just put my exterior Wi-Fi router's IP (192.168.1.1) as the DNS server... I think I did that... so to what DNS server do you refer?
That sounds right. In my case, there is a DNS server on my LAN, and that's the address I used. By default, my guest OS didn't know about it so I had to manually add it.
markfilipak wrote:
ASeales wrote:and adjust the Windows firewall to allow my host to connect to it.
I think that's not needed if the exterior router does DNS. (I don't like to punch holes in my firewall.)
Nothing to do with DNS. My guest was able to access the internet file, but my host was not allowed to connect to my guest(my host is Linux, my guest is WIndows). I want my host to access the guest, so I had to disable the Windows firewall to allow this. Alternatively, I could have opened up specific ports, but since my guest is not accessible to the world, I'm not bothered about completely disabling it.

If you don't need your host to access your guest, then you don't need a host-only adaptor. NAT will do fine.
markfilipak2
Posts: 173
Joined: 15. Jul 2012, 18:23
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Linux Mint 18
Location: Ohio

Re: Host-Only guest can't reach the net... - Solved

Post by markfilipak2 »

Thanks for the tips, ASeales. When I do what I think is needed (vis-a-vis DNS & gateway IP), I get in trouble. So I'm going to take it slowly this time. If you would kindly take a look at the attached file (I didn't know about the "route" cmd!), I'd appreciate your thoughts.
Guest ipconfig & routes.txt
(1.94 KiB) Downloaded 958 times
It sure seems like Host-only includes a router to me! Right now, the host side of Host-only is unreachable in the Guest. Thanks in advance - Mark.
B0zmeister
Posts: 1
Joined: 10. Aug 2013, 15:51

Re: Host-Only guest can't reach the net... - Solved

Post by B0zmeister »

Yeah I had this problem it was a total pain! But I solved it by simply installing Squid Cache Proxy server on my physical PC, and that way - my host-only internet virtualbox PCs could connect to the internet !

I did a quick 3 minute guide here - for anyone who want's to how it works !
b0zmeister,wordpress,com\allowing-host-only-virtualbox-guest-to-connect-to-the-internet
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Host-Only guest can't reach the net... - Solved

Post by mpack »

I don't know why anyone would struggle - or write blogs - to give host only mode VMs access the internet. The whole point of the feature is that you not access the internet. If you want internet access then you would use one of the other built in networking modes, such as NAT or bridged. "Host Only" == "In a private network where the only accessible physical PC is the Host".
boomyd
Posts: 1
Joined: 25. Jan 2016, 00:58

Re: Host-Only guest can't reach the net... - Solved

Post by boomyd »

I know why someone would struggle with this: Let's say you want to do it the way vmware does: have one virtual network card connect to a virtual router, like how vmware does it. In physical reality, one cable plugged from the computer into a router enables it to access other computers on the LAN, and the internet. On the same cable. This is currently not possible in VirtualBox. It is SUPPOSED to be possible with "Nat Network" but that is broken as of 5.0.14 on Linux Mint 17.3. I have googled solutions, but they all say to create another virtual LAN device. I want virtualbox to be able to simulate a small real life LAN with internet access, which shouldn't require each machine having two LAN cards/connections. Please test setting up "NAT Network" for a guest in Linux, and verify that "NAT Network" simulates a real life router for the guest, as far as access to other guests and the Internet. From the guest's point of view, there would be TWO routers daisy-chained to each other. One router is the virtual "NAT Network" router and one is the real life router the host is networked to. I believe this is what VMWare does. It would be nice if virtualbox's "Nat Network" (not the same as plain NAT) were to work this way. If there is a workaround/special way that works in Ubuntu 14.04, I'd like to know. If the "NAT Network" is known to be broken in Linux, then that brings me back to "This is why someone would struggle with this." Thanks for anything you or anyone can do.
BillG
Volunteer
Posts: 5100
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Host-Only guest can't reach the net... - Solved

Post by BillG »

The host only network is deliberately designed to not route to any other network. That is why it is called host only. The IP given to the guest does not have a default gateway, so it is incapable of routing to any other network - it can see only the host and guest interfaces which are in the same IP subnet (192.168.56.x).

It could be modified to be a routable network which could be routed to the Internet, but that is not what it does by default and is not what it was designed to do.
Bill
ironmaq
Posts: 1
Joined: 9. Oct 2017, 20:39

Re: Host-Only guest can't reach the net... - Solved

Post by ironmaq »

This is what worked for me.
The link was helpful in setting up Bridge network with Host(Wifi) and Guest(Host-only adapter). It worked in corporate network as well.

www dot windowscentral dot-com
/how-set-and-manage-network-bridge-connection-windows-10

However ssh (like to git) never worked for me in corporate network.
Locked