VMware Interfaces Tutorial


To totally unlock this section you need to Log-in


Login

If you are new to VMware and the concept of Virtual Machines, or even if you have been working with them for a while but don’t quite understand how the Virtual Machine accesses the network through your host machine, then this article is for you. This VMware interfaces tutorial will guide you on how to manage properly VM nets from inside the VMware program.

Assumptions

But let’s begin with the basics. we will assume that you have installed some version of VMWare for this article – and in particular VMWare Player and that your host machine is a Windows PC of some vintage. The principles hold true for all versions of VMWare, and similar concepts apply for other virtualization platforms.

We’ll also assume you understand the concept of a Host Machine (that’s your PC) and a Guest Operating System (that’s the OS that’s running on your Virtual Machine). Finally, we’ll assume your Host PC obtains its IP address and settings via DHCP.

Your Host PC

When you installed VWMare Player, your Host PC gained two virtual interfaces. You will see these interfaces turn up in several different places; on your host machine, in your VMWare Configuration and possibly linked to any Guest OS you run.

On your host machine, you can see them when you run the ipconfig command, or (for the GUI junkies) in your Network Settings wherever that lives in whichever version of Windows you are running (we are using Windows Vista/7 on the host machine). These new interfaces will be called VMnet1 and VMNet8. Your regular adapter is usually known as Local Area Connection.

C:\>ipconfig /all

Windows IP Configuration

Ethernet adapter VMware Network Adapter VMnet1:
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet1 DHCP Enabled. . . . . . . . . . . : No IPv4 Address. . . . . . . . . . . : 192.168.80.1(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :
Ethernet adapter VMware Network Adapter VMnet8:
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8 <snip> DHCP Enabled. . . . . . . . . . . : No IPv4 Address. . . . . . . . . . . : 172.16.101.1(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : nnk.com.au Description . . . . . . . . . . . : Intel(R) Wireless WiFi Link 4965AGN DHCP Enabled. . . . . . . . . . . : Yes IPv4 Address. . . . . . . . . . . : 192.168.1.105(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Tuesday, 19 July 2011 10:14:59 PM Lease Expires . . . . . . . . . . : Wednesday, 20 July 2011 4:14:58 PM Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.12 DNS Servers . . . . . . . . . . . : 192.168.1.12

Note that both VMnet1 or VMnet8 have NO default gateway, are NOT DHCP enabled and have NO DNS server configured. These interfaces are set up by VMware Player, and we will explore them in more detail later. The Local Area Connection for this Host PC does have DHCP configured, has been told the DNS server is at 192.168.1.12 and been assigned a default gateway of 192.168.1.1.

Key Point #1 – Your host PC has some extra interfaces known as VMware Network Adapter VMnet1 and VMware Network Adapter VMnet8. We’ll refer to them as VMnet1 & VMnet8 from now on. Note that these adapters have IP addresses already.

Next, look at VMWare Player. So that we are all playing the same game, we’ll suggest you begin to create a new Virtual Machine (VM) for this exercise.

To create your VM in VMware Player, click File->Create a New Virtual Machine; Select “I will install the operating system later“; click Next; Choose a guest operating system (we choose Linux/Ubuntu) and click Next; name your Virtual Machine and click Next; allocate a small amount of space for the Disk Capacity (we used 2GB) and click Next; then finally click Finish.

Now from the main VMware Player Window, select your new (or existing) VM and select Edit virtual machine settings; and in the Hardware list, select your Network Adapter. You will see three choices on the right hand side:

VMware Interfaces Tutorial

It is the Network connection section that we want you to look at.

Here you see three options that correspond directly to the output of the ipconfig command you issued earlier on your PC; Bridged, NAT and Host-only.

Bridged Network connection

The Bridged networking option is the easiest to understand. If you choose to link your guest OS’s Network Adapter in Bridged mode, it will share the network interface with the Host.

If your guest OS automatically obtains an IP address it will be on the same subnet as the host, the host will be able to ping the guest, and the guest will be able to ping the host and any other devices on that subnet directly. Other devices on this subnet will see the guest as another PC on the network with its own IP address and own MAC address.

Here is the resulting configuration on an XP guest running on the Vista/7 host referred to above:

C:\>ipconfig /all

Windows IP Configuration
Host Name . . . . . . . . . . . . : PC Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. . . . . . : nnk.com.au
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : nnk.com.au Description . . . . . . . . . . . : VMware Accelerated AMD PCNet Adapter Physical Address. . . . . . . . . : 00-0C-29-D4-43-68 Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 192.168.1.150 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.12 DNS Servers . . . . . . . . . . . : 192.168.1.12 Lease Obtained. . . . . . . . . . : Wednesday, July 20, 2011 8:24:48 AM Lease Expires . . . . . . . . . . : Wednesday, July 20, 2011 8:24:48 PM

Four things to note:

  • The DHCP assigned IP address, 192.168.1.150 with Subnet Mask 255.255.255.0 is on the same subnet as the Local Area Connection interface of the host PC (192.168.1.105).
  • The IP address of the DCHP server (192.168.1.12) is the same DHCP server that allocated the Host PC’s address.
  • The IP address of the DNS server (192.168.1.12) is the same DNS server that the Host PC uses.
  • The IP address of the Default Gateway (192.168.1.1) is the same Default Gateway that the Host PC uses.

This is illustrated in the following diagram:

VMware Interfaces Tutorial

Host-only Network connection

The NAT and Host-only network connections are a little harder to understand than a Bridged connection, and these link to the VMnet8 and VMnet1 network adapters that you see on your host machine respectively. I’ll deal with the Host only link to VMnet1 first.

When VMware created the VMnet1 interface, it also created a process that acts as a DHCP server for VMnet1. So if you link your guest’s network interface to the host-only option, you will find that it will automatically be allocated an IP address by the host on the same subnet as VMnet1. Here is an example of an IP address configuration given to a XP PC when its Network Interface was set to Host-only mode:

C:\>ipconfig /all

Windows IP Configuration
Host Name . . . . . . . . . . . . : PC Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. . . . . . : nnk.com.au
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : localdomain Description . . . . . . . . . . . : VMware Accelerated AMD PCNet Adapter Physical Address. . . . . . . . . : 00-0C-29-D4-43-68 Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 192.168.80.129 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : DHCP Server . . . . . . . . . . . : 192.168.80.254 DNS Servers . . . . . . . . . . . : 192.168.80.1 Lease Obtained. . . . . . . . . . : Wednesday, July 20, 2011 9:08:55 AM Lease Expires . . . . . . . . . . : Wednesday, July 20, 2011 9:38:55 AM

Four things to note:

  • The DHCP assigned IP address, 192.168.80.129 with Subnet Mask 255.255.255.0 is on the same subnet as the VMnet1 interface of the host PC (192.168.80.1).
  • The IP address of the DCHP server 192.168.80.254 (where did that come from?) is also on the same subnet as the VMnet8 interface of the host PC
    There is NO Default Gateway.
  • The DNS server is the IP address of your host’s VMnet1 interface, although in actual fact it won’t resolve names for you at all anyway.

The purpose of the host-only interface is to allow you to set up a virtual machine that can only be seen by your host machine (and any other guest virtual machines it is hosting). It is a network-in-a-box. Your box – ie your host PC. The DHCP server component has its own IP address (192.168.80.254 above), and the VMnet1 interface provides a virtual shared Ethernet segment between your host and the guest virtual machine(s).

No packets on this network will ever leave your host PC or be seen by anyone monitoring your host NIC. It is therefore inherently secure and gives you a great way to test applications in a secure environment. Note, however that if your host is hosting multiple guest virtual machines, and those VMs are using the host-only networking connection, then ALL packets from ALL machines attached to the VMnet1 interface can be seen by EVERY virtual machine.

The following diagram summarises this:

VMware Interfaces Tutorial

NAT Network connection

Similar to VMnet1, when VMware created the VMnet8 interface, it also created a process that acts as a DHCP server, a DNS server, and a NAT router for VMnet8. You can see that VMnet8 does a lot more than VMnet1. Here is an example of an IP address configuration given to a XP PC when its Network Interface was set to NAT mode:

C:\>ipconfig /all

Windows IP Configuration
Host Name . . . . . . . . . . . . : PC Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. . . . . . : localdomain
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : localdomain Description . . . . . . . . . . . : VMware Accelerated AMD PCNet Adapter Physical Address. . . . . . . . . : 00-0C-29-D4-43-68 Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 172.16.101.128 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 172.16.101.2 DHCP Server . . . . . . . . . . . : 172.16.101.254 DNS Servers . . . . . . . . . . . : 172.16.101.2 Lease Obtained. . . . . . . . . . : Tuesday, July 19, 2011 7:42:18 AM Lease Expires . . . . . . . . . . : Tuesday, July 19, 2011 8:12:18 AM

Four things to note:

  • The DHCP assigned IP address, 172.16.101.225with Subnet Mask 255.255.255.0 is on the same subnet as the VMnet8 interface of the host PC.
  • The IP address of the DCHP server 172.16.101.254 is also on the same subnet as the VMnet8 interface of the host PC.
  • You have a default gateway of 172.16.101.2 (again, where did that come from?).
  • The DNS server is also 172.16.101.2.

The purpose of the NAT interface is to allow your VM access to external devices without using another IP address from the host’s subnet as required when using a Bridged networking connection. This is achieved by using a DHCP server function just like with the host-only connection to VMnet1, as well as giving the guest a DNS server and default gateway at yet another IP address which is equal to the VMnet8 interface IP address plus 1.

The following diagram illustrates this:

VMware Interfaces Tutorial

Key Point #2 – Your guest PC’s network adapter is tied to one of three possibilities:

Bridged directly to the host network adapter where it is accessible by any device that can access your Host PC.
Host only, where is can only communicate with your host’s VMnet1 interface.
NAT, where your host can communicate directly with your host’s VMnet8’s interface, but more importantly, your host PC provides a NAT router process that serves as a default gateway and DNS server, and forwards packets on your guest’s behalf after swapping your guest’s private IP address for the host’s Local Area Network Connection’s IP address.

Where did those DHCP Servers and DNS come from?

As promised earlier, I’ll delve a little deeper into the VMware host configuration. To do this, you’ll have to run the vmnetcfg.exe utility that comes with VMware Player – but it’s not easy to find. See this post to learn how to extract the vmnetcfg.exe file from your VMware Player installer file.

Running vmnetcfg.exe on your host machine shows the following interface:

VMware Interfaces Tutorial

Here you see that there are actually ten virtual interfaces, named VMnet0 through to VMnet9. Note that you don’t see any reference to VMnet0 (or any other bridged interfaces) on your host machine’s IP config. That’s because a bridged interface gives a direct physical connection to a particular interface. If you have more than one physical interface, such as an Ethernet adapter AND a Wireless adapter, you can create custom bridged interfaces for each adapter. If your host PC supports VLANs (like my Macintosh) then you can even bridge virtual interfaces to VLAN interfaces on the Host PC.

If you take a look at the VMnet1 (Host-only) configuration, you can see that enabling the DHCP component is an option that can be turned on and off.

Clicking on the DHCP Settings button brings up the DHCP Settings, such as this:

VMware Interfaces Tutorial

As it turns out, the IP address of the DHCP server (as shown in your Guest IP config) will always be the LAST IP address of the range shown – in this case 192.168.80.254.

For a host-only configuration, there is no default gateway address, and no DNS address (even though the DHCP server allocates the VMnetn IP address as a DNS). Your VMnetn adapter on the host PC will always be allocated the first IP address available in the Subnet IP range defined. (Be careful it does not clash with the DHCP range of addresses or you will get Duplicate Address problems)

Finally, I’ll take you to look at the NAT connection configuration on VMnet8:

VMware Interfaces Tutorial

We won’t explore the DHCP settings, they are the same as the Host-only configuration, but if you click on the NAT Settings button, you will see that you can specify a gateway IP that will be allocated by the DHCP server. By default, it is the 2nd IP address on the subnet. From here you can see that there is also a DNS Settings button where you can actually specify the IP addresses of DNS servers that you would like to be given as part of the DHCP IP address allocation.

Multiple Adapters

If you want to, you can create additional adapters. These may be Bridged, NAT or Host-only.

Bridged adapters can be linked to any physical interface on your host PC, including logical VLAN interfaces, (if your Host PC supports VLANs). So you can link one Virtual Interface to say your Ethernet adapter, and another to your wireless adapter. However, to do this you must first turn off Automatic Bridging on VMnet0.

Note: after turning OFF Automatic bridging on VMnet0, you can assign physical adapters to specific VMnet interfaces, then go back to VMnet0 and turn Automatic bridging back on.

Automatic bridging is special, and will bridge itself to which ever physical interface gives it the best shot at getting to the internet, and is only possible on VMnet0. Your VMnet0 interface is set up for Automatic Bridging by default.

Also, you can only have one NAT interface, and again VMware will use whichever physical interface your Host PC uses to connect to the internet as the outside interface for your NAT.

By default, all VMNet interfaces are Host-only, but inactive. To activate a Host-only interface, all you have to do is check the Connect a host virtual adapter to this network option. Once you have done that and applied the configuration, you will see an additional adapter on you host PC, such as:

C:\>ipconfig

Ethernet adapter VMware Network Adapter VMnet5:
Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::157c:3277:14c7:26c7%48 IPv4 Address. . . . . . . . . . . : 192.168.195.1 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : Other Options

There are more advanced options as well, and some of them are covered here. But from me, I’ll finish with the key points for this section:

You can configure the settings of your host PC’s virtual adapters using the vmnetcfg.exe utility. Configuration options include changing the IP address ranges used for DHCP address allocation, DNS & NAT default gateway addressing. You can add additional bridged adapters and multiple host-only adapters if required to a maximum of 10 total virtual adapters.