Sub topic 11
Virtual Network Modes
This chapter assumes you know what a host, a guest, and a hypervisor are. It also assumes you know basic networking terms such as IP address, LAN, DHCP, and gateway. The goal is to pick the right virtual network mode for a scenario and to predict what a guest can and cannot reach in each mode.
Why Virtual Networking Exists
A virtual machine (VM) has no physical network card. The hypervisor gives it a virtual network adapter, which the guest operating system sees as an ordinary NIC. The hypervisor then connects that adapter to a virtual switch, which is software that forwards frames between VMs and the outside world.
How the virtual switch connects to the host and to your physical network is the "network mode." The mode decides three things:
- Whether the guest can reach the internet.
- Whether the guest can reach other VMs and the host.
- Whether other devices on your LAN can reach the guest.
The four modes tested on A+ are NAT, bridged, host-only, and internal. Hypervisors name them differently, but the behavior is the same.
NAT Mode
In NAT (Network Address Translation) mode, the hypervisor acts like a small home router. The guest gets a private IP address from a virtual DHCP server. When the guest sends traffic to the internet, the hypervisor rewrites the source address to the host's own address and forwards the traffic through the host's connection.
Key behavior:
- The guest can reach the internet and, usually, other devices on the LAN by going out through the host.
- Devices outside the host cannot start a connection to the guest. Replies to guest-initiated traffic come back, but unsolicited inbound traffic is dropped.
- Several guests on the same NAT network can usually reach each other.
- The guest needs no configuration on the physical network.
NAT is the default in most client hypervisors, such as VirtualBox and VMware Workstation. It is a good choice when a guest only needs outbound access, such as browsing the web or downloading updates. Because the guest is hidden behind the host, NAT also gives a small amount of protection from the LAN.
The drawback shows up when you run a server in the guest. A web server in a NAT guest is not reachable from other computers unless you configure port forwarding. Port forwarding maps a port on the host to a port on the guest.
Bridged Mode
In bridged mode, the virtual adapter connects directly to the host's physical adapter. The guest appears on the physical LAN as its own device. It gets an address from the same DHCP server as every other device, such as your office router, and it has its own MAC address.
Key behavior:
- The guest can reach the internet and the LAN.
- Other LAN devices can reach the guest directly, with no port forwarding.
- The guest is exposed to the same traffic as any physical computer on that network.
Use bridged mode when the guest must act like a real network device. Examples include a test web server that coworkers must browse to, a VM that must be managed by network tools, and a test of a DHCP or network-monitoring setup.
Bridged mode has a few gotchas:
- It consumes an extra IP address from your LAN's DHCP pool for each VM.
- Some networks restrict the number of MAC addresses on a port. This is called port security. A bridged guest can trigger it and get blocked.
- Many wireless networks, and some hotel or guest Wi-Fi networks, will not accept a second MAC address from one client. Bridging over Wi-Fi may fail or behave unpredictably.
- The guest is exposed to the LAN, so it needs its own firewall and patches.
Host-Only Mode
In host-only mode, the virtual switch connects the guests and the host, and nothing else. There is no path to the physical network or the internet.
Key behavior:
- The guest can talk to the host and to other guests on the same host-only network.
- The guest cannot reach the internet or the LAN.
- Nothing outside the host can reach the guest.
Use host-only mode when you want to test something that must stay isolated but still be reachable from the host. An example is analyzing a suspicious file in a guest while you watch it from the host. Another is a development guest running a database that you only access from your own workstation.
A common mistake is to put a guest in host-only mode and then wonder why updates fail. The guest has no internet route in this mode. Some hypervisors let you add a second adapter in NAT mode to provide both isolation for one link and internet access on another.
Internal Network Mode
In internal network mode, guests connect to a named virtual network that exists only among VMs. The host is not part of it. VirtualBox calls this "Internal Network," and Hyper-V calls it an "Internal" or "Private" switch, depending on the exact configuration. For the exam, remember the core idea: guests can talk to each other, and neither the LAN nor the internet is reachable.
The difference between host-only and internal comes down to the host:
| Mode | Guest to internet | Guest to LAN | Guest to host | Guest to other guests | LAN to guest |
|---|---|---|---|---|---|
| NAT | Yes | Yes (outbound) | Limited | Usually yes | No (without port forwarding) |
| Bridged | Yes | Yes | Yes | Yes | Yes |
| Host-only | No | No | Yes | Yes | No |
| Internal | No | No | No | Yes | No |
Note that the exact NAT guest-to-host and guest-to-guest behavior varies by product. The table shows the typical result you should expect on the exam.
Internal networks suit a lab that mimics a small company network, with a domain controller guest and several client guests, all cut off from everything else. The VMs need an address source. Since no virtual DHCP server is provided in a pure internal network, you often configure static IP addresses or run a DHCP server in one guest.
Choosing a Mode
Exam wording usually points to one mode. Match the phrases:
- "Only needs to browse the web" or "default setup": NAT.
- "Must receive its own IP address on the corporate network" or "other users must connect to it": bridged.
- "Isolated from the network but accessible from the host": host-only.
- "VMs communicate only with each other": internal.
Checking the Mode from Inside the Guest
You can often infer the mode by looking at the guest's IP address and gateway. A guest in NAT mode in VirtualBox typically gets an address such as 10.0.2.15, with a gateway of 10.0.2.2. A bridged guest gets an address in the same subnet as the host. Run these commands in a Linux guest to look.
ip addr show
ip route show
ping -c 3 8.8.8.8Compare the guest's address with the host's address. If both are in the same subnet, such as 192.168.1.x, the guest is bridged. If the guest's subnet differs and it still reaches the internet, it is behind NAT. If the ping fails and the guest has an address, you may be in host-only or internal mode.
On a Windows guest, the equivalent is:
ipconfig /all
ping 8.8.8.8Security Considerations by Mode
Network mode is the first isolation control for a VM. Choose the most restrictive mode that still lets the guest do its job.
- Use host-only or internal mode for malware analysis and for testing untrusted software.
- Use NAT for general guests that need outbound access, since it blocks unsolicited inbound traffic.
- Use bridged mode only when the guest must be visible on the LAN, and treat the guest like a physical machine: patch it, run a firewall, and use antivirus.
Common Troubleshooting Cases
| Symptom | Likely cause | Fix |
|---|---|---|
| Guest has no internet in host-only mode | Host-only has no route outward | Switch to NAT, or add a NAT adapter |
| Coworkers cannot reach a web server in the guest | Guest is in NAT mode | Switch to bridged, or add port forwarding |
| Bridged guest gets no IP address on Wi-Fi | Wireless network rejects the second MAC address | Use NAT, or use a wired connection |
| Guests in internal mode get no IP address | No DHCP server on the internal network | Set static IPs, or run DHCP in a guest |
| Guest cannot reach the host | Guest is in internal mode, or the host firewall blocks it | Use host-only mode, or allow the traffic in the firewall |
Key Points
- NAT shares the host's connection and hides the guest from inbound traffic. It is usually the default.
- Bridged puts the guest directly on the physical LAN with its own IP address and MAC address.
- Host-only connects the guest to the host and other guests, and nothing else.
- Internal connects guests only to one another.
- Pick the most restrictive mode that meets the need.
Exercise
A technician runs a Windows 7 guest to test a legacy application. The guest must not reach the corporate LAN, but the technician must copy files to it from the host. Which network mode fits best, and why would bridged mode be a poor choice?
Show answer
Host-only mode fits best. It lets the host and guest communicate while keeping the guest off the LAN and the internet. Bridged mode would place the unpatched legacy guest directly on the corporate network, exposing it to attack and exposing other devices to it.
Exercise
A developer runs a web server in a VM and needs coworkers on the office LAN to browse to it using the VM's own IP address. The VM is currently in NAT mode and coworkers cannot connect. What should the developer change?
Show answer
Change the adapter to bridged mode so the VM gets its own address on the office LAN. Alternatively, keep NAT and add a port forwarding rule, but then coworkers would use the host's IP address and the forwarded port rather than the VM's own address.
Exercise
You build a lab with one domain controller VM and three client VMs. The lab must have no connection to the host, the LAN, or the internet. Which mode do you choose, and what must you plan for regarding IP addresses?
Show answer
Use internal network mode. Because the network has no virtual DHCP server, assign static IP addresses to the guests or run a DHCP service in one of the guests.