Sub topic 11
Virtual Network Modes
This chapter assumes you know what a hypervisor and a virtual machine (VM) are, and that you understand IP addresses, a LAN, and the internet. It covers the four virtual network modes tested on A+ Core 1 and how to choose between them.
How a VM Gets Network Access
A VM has a virtual network adapter. The hypervisor connects that adapter to a virtual switch on the host. The mode you choose decides what the virtual switch connects to: the physical network, the host only, or nothing outside the VM group.
The Four Modes
NAT
In NAT (Network Address Translation) mode, the hypervisor acts like a small router. The VM gets a private address from a virtual DHCP service, and its traffic leaves through the host's IP address.
- The VM can reach the internet and the LAN.
- Devices on the LAN cannot start a connection to the VM.
- This is the default in most client hypervisors.
Bridged
In bridged mode, the VM's virtual adapter attaches to the host's physical adapter. The VM appears on the LAN as its own device, with its own MAC address and an IP address from the LAN's DHCP server.
- Other LAN devices can reach the VM directly.
- It suits a VM that must act as a server, such as a test web server.
- The VM is exposed to everything on that network.
Host-only
In host-only mode, the VM can talk to the host and to other VMs on the same host-only network. It has no route to the LAN or the internet.
Internal
In internal mode, VMs on the same named internal network can talk to each other. The host cannot reach them, and they have no outside access. This is the most isolated mode that still allows VM-to-VM traffic.
Comparison
| Mode | VM to internet | LAN to VM | VM to host | VM to VM |
|---|---|---|---|---|
| NAT | Yes | No | Limited | Usually no |
| Bridged | Yes | Yes | Yes | Yes |
| Host-only | No | No | Yes | Yes |
| Internal | No | No | No | Yes |
Choosing a Mode
Start from what the VM needs to reach.
- The VM only needs to browse the web or download updates: choose NAT.
- Other computers on the LAN must connect to the VM: choose bridged.
- You want a test VM that you manage from the host but that must not go online: choose host-only.
- You are testing malware behavior or a multi-VM lab that must be fully cut off from the host: choose internal.
Common Errors
- A bridged VM gets no address. The physical adapter may be on a network that blocks extra MAC addresses, such as some Wi-Fi networks or secured switch ports. Try NAT instead.
- A LAN device cannot reach a NAT VM. This is expected behavior. Switch to bridged mode or add a port forward.
- Two VMs cannot communicate. Check that both use the same mode and the same named network. VMs in different internal networks are isolated from each other.
- A VM has no internet in host-only mode. This is by design. Use NAT or bridged mode if it needs outside access.
Exercise
A technician is analyzing a suspicious file in a VM. The VM must be able to exchange data with a second analysis VM, but it must not reach the host, the LAN, or the internet. Which virtual network mode should the technician choose?
Show answer
Internal. Internal mode allows traffic only between VMs on the same internal network. Host-only would allow access to the host, and NAT and bridged would allow outside access.
Exercise
A developer runs a test web server in a VM. Coworkers on the same LAN need to open it in their browsers. Which mode fits, and why does NAT not work by default?
Show answer
Bridged. It gives the VM its own LAN IP address, so coworkers can reach it directly. In NAT mode, the VM sits behind the host's address and LAN devices cannot start connections to it.