Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Network Address Translation is the technique used by your home router to connect all the computers in your house to the Comcast ISP using only the one IP address Comcast has assigned to your home router. In the context of virtual machines, NAT is used to allow a VM to access the Internet through the one network connection that the host computer already has. However, unlike bridging, the VM does not get a network address, is not visible to other computers on the network, and by default is limited to client operations (browsing, downloading files, applying patches).

A specific service on the VM can be made available to the real network through a configuration option called Port Mapping. Each service runs on a specific numbered port. Oracle Database Servers just to name one example default to using port 1521. You can configure a NAT connection to allow all outbound client connections from the VM to the Internet, but then assign one or more port numbers on the host computer to services that actually run on the VM. For example, you could map port 1521 on the host computer to port 1521 on the VM. Then the rest of the network would see what appears to be an Oracle database server on your computer, although it would actually be running on the VM instead of on the host. Port mapping is reasonable for a very limited number of services and is best when the host computer is not trying to offer the same service as the VM.

Internal Network

The Internal Network option connects virtual machines to each other over a simulated LAN. You can create more than one named Internal Network, so you can connect all your VMs to the same network or you can partition VMs into different isolated networks. Since you control all the VMs, having more than one Internal Network really doesn't make much sense.

The problem is that the Internal Network cannot communicate with the Internet or the host computer. The VMs can only talk to each other, and that is generally not enough to make this option useful. Internal Networks are an old feature that today have probably been completely replaced by the NAT Network.

NAT Network

The NAT Network option combines the features of Simple NAT to those of the Internal Network. The VMs share a virtual network that allows them to communicate with each other, but then a service on the host computer provides the same function as the Comcast router box on a home network. It translates client requests from all the VMs into requests from the host computer using the one host computer address on the real network.

Each virtual machine has to have an IP address. Because this is a private network inside your machine, the simplest approach is to use one of the 192.168.*.* subnets just like a home network. You could dynamically assign addresses by enabling a DHCP function on the host computer, but it is probably safer to manually assign addresses to each computer with static configuration. Then each machine has a fixed IP address you can configure to other machines.

You can do Port Mapping, but now you map a host port number to a virtual machine IP address and port number.

Host Only Network

The Host Only Network is something like the Internal Network. However, it generates a dummy LAN adapter on the host computer that appears to be connected to that network. Now the host computer can communicate over that adapter with the VMs.

Machines can have more than one network adapter. Most laptops have a wired and a wireless adapter. Phones have 4G, WiFi, and bluetooth adapters. This works transparently for all client programs. It should work correctly for server programs as well, except that running a server on a machine with multiple LAN adapters used for different purposes sometimes requires careful configuration. Every so often you find a program that tries to connect to the wrong LAN and ends up trying to talk to the VMs instead of to the Internet. Such programs should have been written correctly, but the bottom line is that the Host Only dummy network adapter on the host computer can sometimes confuse programs. So you should really ask if you need for the host operating system to be able to talk to the VMs, or can you do everything you want with shared directories and the VM user interface window.

Summary

The Bridged network solution is simplest at home or on a private network behind a firewall. It can be used on a campus network but there may be paperwork to fill out for each VM and it may not be worth the trouble.

The NAT Network provides a private network connection between the VMs with a firewalled connection from them to the outside world. This doesn't provide access from the host computer to the VMs, but generally that is not a real requirement. If you need the host computer to talk to the VMs, then you may also need a Host-Only network in addition to the NAT Network (because the NAT Network does not provide communication from Host to VM, and the Host Only network does not provide a connection from the VM to the Internet). This makes both the host and the VM networking environment more complicated 

In VirtualBox, when you configure a LAN adapter you can select NAT as the network management option from a pulldown menu. Since VirtualBox is simply an application in the host Windows system, the NAT function is simply part of the LAN adapter simulation logic in the application. When the VM sends IP traffic over the adapter, the VirtualBox LAN sumulation logic changes the IP address and port number and then sends the data using the Windows network API. VirtualBox certainly sees all the data, but it doesn't expose the VM to anything else running on the host OS.

In Hype-V the VM runs separate from the host OS. The host and VM communicate over a LAN simulation provided by the hypervisor. Since the VM is external rather than hiding inside an application, the simulated network between the host system and the VM can also be used by other programs. So the host and VM can share files or make database requests across systems. NAT is the Default network connection created by Hyper-V when you install it, so it requires no configuration. It does, however, generate one emulated Network adapter added to the Network Connections configuration on the host computer. 

Host Only Network

This is the name that VirtualBox uses to reference a simulated LAN adapter created in the host operating system that is then virtually connected to one or more VMs. Unfortunately, in VirtualBox this simulated network doesn't automatically get a NAT function added, so if this is the only type of LAN adapter defined to a VirtualBox VM, then the VM can talk to the host computer but not to the Internet. Of course, there are several separate software solutions that add NAT services to a Windows system (Internet Connection Sharing, NAT32, and WinGate all come to mind). Unfortunately, although VirtualBox has NAT services built in, a pure NAT adapter doesn't allow the host to talk to the VM, while a Host-Only network doesn't allow the VM to talk to the Internet. As a results, in VirtualBox you have to define two LAN adapters (one NAT and one Host-Only) to get both functions, while in Hyper-V the Default combines both services and requires no extra configuration.