VMware workstations network connection–“Host-only”, “Bridged” and “NAT”

VMware provide THREE network connection settings for the virtual machines: Host-only, bridged and NAT. Before we look into the configuration, we talk about the 20 VMnets that VMware provided. By default VMnet1 and VMnet8 will appear to your host after the installation of VMware, VMnet0 (auto-bridged) can be seen in the Virtual network editor after you enter the editor.

1. Bridged (Connect the VMs directly to the external network)

The VM and host are in the same LAN and VM was assigned an IP (192.168.1.127) from the Gateway (192.168.1.1) of the network where host (192.168.1.109) resides if DHCP is enabled in the network.

Host IP (windows: ipconfig):

Wireless LAN adapter WLAN: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::5951:8c6d:b973:4203%13

IPv4 Address. . . . . . . . . . . : 192.168.1.109

Subnet Mask . . . . . . . . . . . : 255.255.255.0

Default Gateway . . . . . . . . . : 192.168.1.1

VM IP (Ubuntu: ifconfig -a):

joy@ubuntu:~$ ifconfig -a

ens33: flags=4163 mtu 1500 inet 192.168.1.127 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::7c7a:7313:3608:3675 prefixlen 64 scopeid 0x20 ether 00:0c:29:86:8c:27 txqueuelen 1000 (Ethernet) …

joy@ubuntu:~$ route -n

Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 ens33 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 ens33 192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33

When adding new network as “bridged”, it is normal to see the error: Cannot change network to bridged: There are no un-bridged host network adapters This issue occurs when auto bridging is enabled in the virtual network editor. To resolve this issue, bridge your machine to a specific physical network adapter. Changing VMnet0 adaptor first and then add new network.

2. NAT (Share host’s IP address with VMs)

NAT mode will mask all network activity as if it came from your Host OS. VM will be assigned another LAN IP (192.168.119.130) at the same network with VMnet8 (192.168.119.1, by default VMnet8 is on NAT mode). However, VMnet8 does not perform like a gateway to VM, the gateway IP 192.168.119.2 is configured under NAT setting. Host can ping 192.168.119.130 successfully but fail to ping 192.168.119.2.

Host: Ethernet adapter VMware Network Adapter VMnet8: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::f863:4276:b4c0:4170%5 IPv4 Address. . . . . . . . . . . : 192.168.119.1 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :

VM: joy@ubuntu:~$ ifconfig -a ens33: flags=4163 mtu 1500 inet 192.168.119.130 netmask 255.255.255.0 broadcast 192.168.119.255 inet6 fe80::7c7a:7313:3608:3675 prefixlen 64 scopeid 0x20 ether 00:0c:29:86:8c:27 txqueuelen 1000 (Ethernet)

joy@ubuntu:~$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.119.2 0.0.0.0 UG 100 0 0 ens33 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 ens33 192.168.119.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33

3. Host-only (Connect VMs internally in a private network)

Pretty much the same as NAT connection however VM is not able to connect to Internet from the Host. VM has a same LAN IP (192.168.233.133) with the host VMnet1 (192.168.233.1) without a specific gateway hence VM would not be able to access the network outside the host. This is particularly useful when your VM’s behavior will cause conflicts (like you’re implementing VM as a DHCP server) or not necessary exposed to the Host outside LAN.

Host: Ethernet adapter VMware Network Adapter VMnet1: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::b835:ffac:a9f1:c8a9%9 IPv4 Address. . . . . . . . . . . : 192.168.233.1 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :

VM: joy@ubuntu:~$ ifconfig -a ens33: flags=4163 mtu 1500 inet 192.168.233.133 netmask 255.255.255.0 broadcast 192.168.233.255 inet6 fe80::7c7a:7313:3608:3675 prefixlen 64 scopeid 0x20 ether 00:0c:29:86:8c:27 txqueuelen 1000 (Ethernet)

joy@ubuntu:~$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 ens33 192.168.233.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33

Test network accessing: I’m using the one simple way to start an http server in the VM and test if a host can access the VM service; using web browser to test if VM could get access to the Internet as host does.

joy@ubuntu:~$ python -m http.server 8000

Host can access the service running on VM under all three modes with the VM IP:port number, however under Host-only mode, VM is not able to connect to Internet as the other two modes.

Virtualisation–Hypervisor Classification

Virtualisation technology is never a new thing, my first experience with virtual machine was back to 2009 when I was playing with SISCO routers and switches with GNS3 lab environment. Throughout the years of studies and working, VMware become my frequently used tool in implementing the various OS and having fun. As we are expose to the cloud computing, it is necessary to acknowledge that virtualisation and cloud computing are different. Virtualisation is a technique component in cloud computing. You may heard about the concept of hypervisor, or virtual machine monitor (VMM), it is computer software, firmware or hardware that creates and runs virtual machines. Continue reading Virtualisation–Hypervisor Classification