VMware Communities
mmoser
Contributor
Contributor

Unable to connect from guest to host when using NATted network connection

I am having trouble to connect from guests (running e.g. Windows 7 or Windows Server 2008 to the host (running VMware Workstation on Windows 😎 when the network adapter mode chosen for the guest is NAT. Things work fine in bridged mode, but occasionally, e.g. when on a wireless network I can only use NAT mode. In NAT mode the guests *do have* access to the network, e.g. I can browse the web and I can also ping the host from the guests using its name (not only via IP address).But any other attempt to access the host (and specifically all attempts to mount a share on the host on which I typically prepare files that I want to install on the guests) fails.

The error message is:"The network connection could not be found."

Not sure, whether that's relevant here: I have defined all VMware network adapters VMnet[0,1,8] as NDIS_DEVICE_TYPE_ENDPOINT on the host's side to avoid that Windows' firewall interferes here.

And as I said: when I switch to bridged mode, then I can access the host and mount the shares without any problem. But why does this not work any more when I switch to NAT mode? Any idea, what could cause this problem?

M.

Tags (2)
0 Kudos
4 Replies
BobAgi
Enthusiast
Enthusiast

I think that this is exactly what NAT does. The host just acts as a router with Network Address Translation from the guest onwards out to the network the host is connected to.

If you want a network connection to the guest that will not do this and will not be lost if the host cannot get a network connection (i.e. to a WiFi router) then I think your only option is host only networking.

This isolates the connection between host and guest from all other connections but it stays put no matter what.

On the downside: The guest will not have Internet access.

I have used this a lot when I did not want to use bridged networking since it would clutter up the router (especially at customers) and my only need was to be able to communicate host-guest.

0 Kudos
mmoser
Contributor
Contributor

The issue is, that in many of those networks where one *needs* to use NATed mode (because one only can use a single MAC, e.g. in many hotel WLANs or via cell-phone/WAN connections) one can not register the host's name with DNS. The host is and remains thus "invisible" for the guest's name resolution and then "can not be found", which is most annoying.

What I found out meanwhile is:

In NATed mode (unless specified differently) the host always has address x.y.z.1 plus there is a virtual DNS server provided at address x.y.z.2. If I enter the later address into the guest's DNS settings, then the access from guest to host works immediately!

So first I thought: Bingo! However, if I do so, then there is no "normal" DNS resolution anymore and hence the outside network is invisible, i.e. the guest then can then not properly access internet addresses. At the moment I can only choose to either resolve the host's name or to resolve internet names (or whatever names are resolvable by the host's DNS server).

What thus is missing, is an option to tell that NATed subnet's "virtual" DNS server to relay name resolution to the host's DNS server for the all those names, that it itself does not know. If it would pass on those requests, one could have both: resolve the host's name PLUS resolve all other names. But I haven't found such a flag or setting, yet. I would almost consider that a bug!

Where can I feed in such an option as feature request to VMware?

M.


0 Kudos
BobAgi
Enthusiast
Enthusiast

It would be interesting to know if one can set the guest networking to NAT (which makes the host computer a network router) and thus let the guest have access to the Internet while at the same time be able to communicate with the guest from the host.

Example (current problem for me):

I need a Linux virtual machine (in this case Linux Mint 13) to use as a full webserver for testing a site before it goes live.

So I need to select a networking mode that gives the linux box access to the Internet (for all updates and software I need on the vm).

But I also need to be able to connect to the vm from the host to do the following:

- Update site files in Linux (I will use rsync over ssh here)

- Browse to the test site from all browsers on the host (Chrome, FireFox and IE)

I have now quickly checked a solution as follows:

- Set the network adapter in the vm to use NAT (can actually be switched while the guest is running!)

- Find the IP address the guest now operates on (check the IP address inside the guest using ifconfig for example)

- Try to communicate with that address in the browser

When I did this it worked immediately!

Now I wonder how I can make the address given to the guest via NAT DHCP permanent?

I actually got 192.168.80.157, which looks kind of weird, I had expected something like 192.168.80.2 given that the NAT router runs on 192.168.80.1

What I want to do is to define a reservation such that this guest always gets the same IP address, then I can add that into my hosts file on Win7 and get name resolution that way.

So:

Is there any way to reserve IP address for a guest when using NAT networking on WorkStation7???

0 Kudos
BobAgi
Enthusiast
Enthusiast

Yes there is a way:

See this older post on the subject:

Assign static IP to guest with NAT Virt Network Adaptor?

Also see my new post for the same question:

How to get a DHCP address reservation when using NAT networking?

So after making sure that the DHCP of NAT will always give the guest a fixed address you only have to enter one line into the C:\Windows\system32\drivers\etc\hosts file:

<fixed ip of guest>  <your preferred hostname for the guest>

Example:

192.168.80.10  webdevserver

Note that the hosts file is hidden on Windows7 and can only be edited in an editor opened "as administrator"

0 Kudos