Using host's "hosts" file from within guest

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Twisted Lucidity
Posts: 170
Joined: 18. Feb 2012, 12:42
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Various GNU/Linux
Location: Here
Contact:

Using host's "hosts" file from within guest

Post by Twisted Lucidity »

Host: Win 7 64-bit
Guest: Win 2003 Server 64-bit (NAT)
Guest was migrated from VMWare, not sure if that has any bearing.

My host connects to a corporate VPN and I have various servers recorded in the host's "hosts" file. This allows name resolution to work correctly from the host.
The guest is using NAT, but it cannot resolve these names. Is there anyway to have the name resolution be handled by the host? This would save me having to keep two files in sync.
This guest was migrated from VMWare (where such host-driven name resolution worked), not sure if that has any bearing.

VPN is Cisco, not sure if I am hitting the GRE limitation on NAT but the VPN client states the transport is "IPSec/UDP".
A new account for an old user.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Using host's "hosts" file from within guest

Post by mpack »

Why not just copy the hosts file into the guest?
Twisted Lucidity
Posts: 170
Joined: 18. Feb 2012, 12:42
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Various GNU/Linux
Location: Here
Contact:

Re: Using host's "hosts" file from within guest

Post by Twisted Lucidity »

Well, yes. I could do that, but any changes on the the host would have to be made in all the guests.
If the VBox NAT were (somehow) able to use the host's "hosts" like VMWare, then I wouldn't have to keep all the files in step.

But if I've hit a limitation, then I've hit a limitation.
A new account for an old user.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Using host's "hosts" file from within guest

Post by mpack »

I'm not a networking expert, but AFAIK the hosts file essentially says - if it's listed in the hosts file then don't bother looking up the name, just use this IP instead.

Since the intent is specifically: don't look it up, don't interact with a DNS, I don't understand how the hosts info could be shared between PCs on a network. Unless you scripted some kind of network push of course.
Twisted Lucidity
Posts: 170
Joined: 18. Feb 2012, 12:42
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Various GNU/Linux
Location: Here
Contact:

Re: Using host's "hosts" file from within guest

Post by Twisted Lucidity »

AIUI when using NAT it is the host effectively doing all the networking; so I would have thought the entries in the host's "hosts" file would have had an effect on the guest.

If I have this is the host's "hosts" file

Code: Select all

192.168.0.1 foo
and then I do

Code: Select all

ping foo
from within the guest, I would expect to see responses from 192.168.0.1. At the moment I just get "host 'foo' unknown".

Like I said, "host's 'hosts' file does guest name resolution" behaviour was what I saw when trying VMWare; so I was a bit puzzled when I didn't see it under VBox.
A new account for an old user.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Using host's "hosts" file from within guest

Post by mpack »

Twisted Lucidity wrote:AIUI when using NAT it is the host effectively doing all the networking
That isn't my understanding. My understanding that that the guest still implements a full network stack, however when message packets are transmitted the NIC simulation replaces the "from" address with the host address, and sets a flag. On receipt if that flag is set then it changes the "to" address and redirects the packet to the guest, and resets the flag. As far as the guest is concerned it is doing everything it should as an independant PC. In particular DNS name lookup (or not) as part of the larger transaction.
Twisted Lucidity
Posts: 170
Joined: 18. Feb 2012, 12:42
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Various GNU/Linux
Location: Here
Contact:

Re: Using host's "hosts" file from within guest

Post by Twisted Lucidity »

Ok then. VMWare must be doing something totally different because in NAT the host's "hosts" file does affect the guest.
A new account for an old user.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Using host's "hosts" file from within guest

Post by mpack »

Perhaps they implement some kind of DNS proxy?
Twisted Lucidity
Posts: 170
Joined: 18. Feb 2012, 12:42
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Various GNU/Linux
Location: Here
Contact:

Re: Using host's "hosts" file from within guest

Post by Twisted Lucidity »

Dunno to be honest - I thought it was a feature of using NAT; but it could be their add-ons doing something extra.

Now I know what I'm dealing with, I'll figure out a way to use a common hosts file for all guests.

Wouldn't have this problem on other operating systems...mumble...grumble...
A new account for an old user.
Post Reply