Oracle VirtualBox provides several network adapter modes to help virtual machines (VMs) connect to external networks, such as the internet. These adapters include:
- NAT
- NAT Network
- Bridged Adapter
- Internal Network
- Host-only Adapter (Plus a few experimental options.)
In this post, we’ll focus on the NAT (Network Address Translation) adapter, which is the default mode for newly created VMs.
What Is a NAT Adapter?
A NAT (Network Address Translation) adapter creates a separate subnetwork for each VM and uses NAT to connect the VM to the internet, keeping it isolated from the host’s local network. In other words, any request from the VM appears to come from the host machine. Although the VM can access the host, the host cannot directly access the VM unless you set up port forwarding or other configurations.
Can Multiple VMs Communicate With Each Other?
By default, multiple VMs using the NAT adapter cannot communicate with each other. One workaround is to use port forwarding for each VM. Another option is to use the specialized host IP address 10.0.2.2 (for example, 10.0.2.2:) to allow some level of communication. However, this can get tricky for multiple VMs, so you may want to explore other adapter modes if you need direct VM-to-VM communication.
How Does NAT Work?
When a VM is set to use NAT, VirtualBox creates a virtual router that manages network traffic for that VM. The VM receives a private IP address from VirtualBox’s built-in DHCP server, and all outbound traffic is translated (NATed) before reaching external networks (like the internet).
In the figure above:
- VM1 and VM2 each use their own NAT table (NAT1 and NAT2).
- Both connect to the host machine’s network interface card (NIC).
- Each VM is on its own isolated subnetwork, so they cannot directly reach each other’s IP addresses.
Step-by-Step NAT Traffic Flow
Outbound Traffic (VM → Internet)
- The VM sends a request (e.g., visiting google.com).
- The NAT engine replaces the VM’s private IP (e.g., 10.0.2.15) with the host’s public IP.
- The request is sent to the internet.
- The response from the external site returns to the host machine.
- VirtualBox forwards the response back to the VM.
Inbound Traffic (Internet → VM)
- Because the VM is behind NAT, unsolicited inbound traffic is dropped.
- Only traffic forwarded via port forwarding rules can reach the VM.
Conclusion
The NAT adapter is a simple and secure way to provide internet access to your VMs without exposing them directly on the host network. If you need more control over network configurations or VM-to-VM communication, consider exploring other VirtualBox network adapters like Bridged or Host-only.
Top comments (2)
It seemed like you were off to a good start, but then just stopped abruptly.
very intuitive!!