VMware Networking (1/3)

Introduction

In this tutorial we will show the various networking possibilities offered by VMware Workstation (version 10 will be used).

After we present the core concepts of virtual networking we will go through the various predefined networks provided:

We will then show how to create custom network configurations on the next page.

Prerequisites

This tutorial requires knowledge of basic networking concepts such as switches and NICs [1]. Having said that people who are learning these basic concepts may benefit from using this tutorial at the same time to see a few concrete examples of network configurations.

The tutorial also assumes basic knowledge of how to create a virtual machine and install an OS on it. In our examples we use Ubuntu Desktop 14.04.1 but pretty much any OS would do as we only want to test connectivity between VMs in different network configurations.

Concepts

A very good introduction to VMware virtual networking is the following document: VMware: Virtual Networking Concepts [2].

Virtual network

A physical network is created by connecting devices to a switch. Similarly a virtual network [3] is created by connecting virtual machines to a virtual switch. VMware virtual switches are named VMnet<N> where N is a number. For instance VMnet0 is the switch used for bridged networking as we will see in the next section.

There are two kind of virtual switches: standard virtual switches and distributed virtual switches. VMware Workstation only supports standard virtual switches so we will only discuss those in this tutorial. VMware ESXi also supports distributed virtual switches which can span several hosts and allow virtual machines on these hosts to connect to the same switch.

Virtual NIC

In the same way a physical machine uses a network interface controller (NIC) to connect to a switch, a VM uses a virtual NIC to connect to a virtual switch. A VM can have more than one virtual NIC to connect to more than one virtual switch. A virtual NIC is assigned a MAC address and from the point of view of the guest OS looks just like a physical NIC.

The default virtual switches

As we mentioned earlier on there are 3 predefined networks. Each of them has a corresponding virtual switch.

You can view these 3 predefined networks in the Virtual Network Editor as shown on Figure 1.

Figure 1:

We will now look at each of these networks in detail.

Bridged

NAT

Host-only

The bridged and NAT options are usually the easiest to setup and use as the VMs that use these options more or less appear as extra machines on the same network as the host. There are cases where more control or isolation is needed. A VM that chooses the host-only networking shares a private network with the host and the other VMs that chose host-only networking.

There is a bug that can affect host-only networking on VMware Workstation on Windows. To know if you are impacted use ipconfig to get the IP address of the "Ethernet adapter VMware Network Adapter VMnet1" adapter. If it is something like 169.254.x.x then there has been some problem and the adapter is not working correctly. More information about the issue and the way to resolve it can be found in VMware: Problem Configuring VMNet1 IP on Win 7 Host [4] and VMware Player [5].

We will now check the behaviour of host-only networking with two examples.

Example network: host and 1 VM

First let's create a new VM called "hostonly1". For this example we use Ubuntu as the guest OS. In the VM creation wizard we choose the "Use host-only networking" option as shown in Figure 2.

Networking Type Selection Dialog
Figure 2: Networking Type Selection Dialog

When using host-only networking VMware Workstation will connect the VM to the VMnet1 virtual switch. The host and a DHCP server are also connected to this switch. Therefore we end up with the network shown on Figure 3.

Host-only network with one VM
Figure 3: Host-only network with one VM

The new VM got its IP address from the DHCP server connected to the VMnet1 switch. We can see the IP address of each machine by running ipconfig (on Windows) or ifconfig (on Ubuntu) as shown below.

ifconfig for hostonly1
xavier@hostonly1:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:ad:a7:ca  
          inet addr:192.168.37.128  Bcast:192.168.37.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fead:a7ca/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:63 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2178 (2.1 KB)  TX bytes:9664 (9.6 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:175 errors:0 dropped:0 overruns:0 frame:0
          TX packets:175 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:21330 (21.3 KB)  TX bytes:21330 (21.3 KB)

xavier@hostonly1:~$
ipconfig for the host (non-VMware adapters have been omitted here)
C:\windows\system32>ipconfig

Windows IP Configuration


Ethernet adapter VMware Network Adapter VMnet1:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.37.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Ethernet adapter VMware Network Adapter VMnet8:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::8959:e003:3f9f:75e4%21
   IPv4 Address. . . . . . . . . . . : 192.168.28.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

C:\windows\system32>

Since the host and the VM are on the same network they can connect to eachother which we verify by pinging one from the other as shown below.

ping from the host to the guest hostonly1
C:\windows\system32>ping 192.168.37.128

Pinging 192.168.37.128 with 32 bytes of data:
Reply from 192.168.37.128: bytes=32 time<1ms TTL=64
Reply from 192.168.37.128: bytes=32 time<1ms TTL=64
Reply from 192.168.37.128: bytes=32 time<1ms TTL=64
Reply from 192.168.37.128: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.37.128:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\windows\system32>
ping from the guest hostonly1 to the host
xavier@hostonly1:~$ ping 192.168.37.1
PING 192.168.37.1 (192.168.37.1) 56(84) bytes of data.
64 bytes from 192.168.37.1: icmp_seq=1 ttl=128 time=0.649 ms
64 bytes from 192.168.37.1: icmp_seq=2 ttl=128 time=0.414 ms
64 bytes from 192.168.37.1: icmp_seq=3 ttl=128 time=0.373 ms
^C
--- 192.168.37.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.373/0.478/0.649/0.124 ms
xavier@hostonly1:~$

Example network: host and 2 VMs

Let's modify the previous example by adding another VM (called hostonly2) with host-only networking.

The network now looks like the one on Figure 4.

Host-only network with two VMs
Figure 4: Host-only network with two VMs

Since all machines are on the same network they can connect to eachother. We have already verified that the host and the hostonly1 VM can ping eachother. By the same logic the host and the hostonly2 VM can also ping eachother so we will not explicitly verify it here. The only interesting point is that hostonly1 and hostonly2 can also connect to eachother which we show below.

ping from hostonly1 to hostonly2
xavier@hostonly1:~$ ping 192.168.37.129
PING 192.168.37.129 (192.168.37.129) 56(84) bytes of data.
64 bytes from 192.168.37.129: icmp_seq=1 ttl=64 time=0.797 ms
64 bytes from 192.168.37.129: icmp_seq=2 ttl=64 time=0.602 ms
64 bytes from 192.168.37.129: icmp_seq=3 ttl=64 time=0.592 ms
^C
--- 192.168.37.129 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.592/0.663/0.797/0.098 ms
xavier@hostonly1:~$
ping from hostonly2 to hostonly1
xavier@hostonly2:~$ ping 192.168.37.128
PING 192.168.37.128 (192.168.37.128) 56(84) bytes of data.
64 bytes from 192.168.37.128: icmp_seq=1 ttl=64 time=1.35 ms
64 bytes from 192.168.37.128: icmp_seq=2 ttl=64 time=0.323 ms
64 bytes from 192.168.37.128: icmp_seq=3 ttl=64 time=0.282 ms
^C
--- 192.168.37.128 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.282/0.651/1.350/0.494 ms
xavier@hostonly2:~$

References

  1. Wikipedia: Network interface controller
  2. VMware: Virtual Networking Concepts
  3. Wikipedia: Virtual network
  4. VMware: Problem Configuring VMNet1 IP on Win 7 Host
  5. VMware Player

blog comments powered by Disqus

Copyright(c) 2006-2017 Xavier Leclercq | Privacy policy

Home
Contact Us
Search