🔥 VirtualBox Network Configuration: NAT & Host-Only Setup14 min read2,791 words

🔥 VirtualBox Network Configuration: NAT & Host-Only Setup

Learn VirtualBox network configuration with NAT & host-only adapters for internet, VirtualBox SSH access, and safer homelab networking—set up fast!

VirtualBox network configurationVirtualBox NAT and host-onlyVirtualBox SSH accessVirtualBox homelab networkingVirtualBox network adapters
🔥 VirtualBox Network Configuration: NAT & Host-Only Setup

A Practical VirtualBox Network Setup for Homelabs

A virtual machine usually needs two things that don't naturally go together: internet access for updates and packages, and a reliable way for your host computer to reach it over SSH. Bridged networking can handle both, but it also puts the VM directly on your physical LAN. That's often more exposure than a development machine - or a quiet homelab - really needs.

A practical alternative is to give the VM two virtual network adapters: NAT for outbound connectivity and Host-Only for communication with the host. The guest uses the host's networking to get to the internet, while you connect to a stable private IP address on the host-only network. This works well for Linux servers, test environments, and small Kubernetes labs.

This guide walks through what VirtualBox's network modes actually do, when a two-adapter setup makes sense, and how to configure it on a Linux guest using NetworkManager. It also covers routing, SSH, basic security, and the common mistakes that make a VM look "connected" when it isn't.

Understand VirtualBox network modes

VirtualBox offers several network attachment types. The best choice depends on who needs to talk to the VM, not just whether the VM needs internet access. And yes - VirtualBox VMs can have more than one adapter, so you don't have to force every requirement into a single mode.

NAT

With NAT, VirtualBox lets a guest make outbound connections through the host's network connection. In practice, that means the guest can usually reach websites, package repositories, and other external services without being assigned a LAN address.

The catch is inbound. With "ordinary" NAT, each VM is generally isolated on its own private network. Other VMs won't automatically be on the same NAT segment, and the host can't typically initiate connections directly to the guest. If you need inbound access, you usually use port forwarding (for example, forwarding a host port to the guest's SSH port).

NAT is a good default when the VM only needs outbound access. It's less convenient when you want to SSH into the guest regularly or have multiple VMs talk to each other.

NAT Network

A NAT Network is a shared virtual network that multiple VMs can join. Guests on that network can communicate with each other while still using NAT for outbound access. For a small multi-VM lab, this often saves you from setting up separate NAT interfaces.

If you also want access from the host, you still typically need port forwarding or an additional interface like Host-Only. If you need both VM-to-VM communication and direct host-to-guest access, combining NAT Network with Host-Only can be a reasonable setup.

Bridged Adapter

A Bridged Adapter connects the VM to the same network as the host by using one of the host's physical network interfaces. The guest can receive an address from the LAN DHCP server and may be reachable by other devices on that LAN.

This is handy when you really want the VM to behave like a separate physical machine. It also changes the risk profile: the VM isn't tucked behind NAT anymore. Reachability depends on your LAN and the firewall rules on the host and guest. Use bridged mode on purpose - especially on office, shared, or public networks.

Host-Only, Internal, and Cloud networks

A Host-Only Adapter creates a private network between the host and any attached VMs. By itself, it doesn't provide internet access. VirtualBox can run a DHCP server for this network, or you can assign addresses manually.

An Internal Network is meant for communication between VMs on the same named internal network. The host isn't included by default, and you shouldn't assume there's DHCP. If you use internal networks, configure addressing (and DHCP, if you need it) for your lab.

VirtualBox also offers Cloud Network support for specific cloud networking services, including Oracle Cloud Infrastructure. That's version- and configuration-dependent, and it's not needed for the straightforward host-and-guest setup in this guide.

Choose a network design that fits the job

Before you change VirtualBox settings, write down what the VM actually needs. In a basic homelab, the common requirements are:

  • The guest needs outbound internet access for updates and downloads.
  • The host needs to connect to the guest over SSH.
  • Other devices on the physical LAN do not need to connect to the guest.
  • The guest may need a stable address for scripts or development tools.

For those, use two adapters:

  1. Adapter 1: NAT for outbound internet access.
  2. Adapter 2: Host-Only for host-to-guest management.

The NAT adapter usually uses VirtualBox's built-in DHCP to configure itself. The Host-Only adapter gets an address on a private subnet shared with the host. For example, your host might be 192.168.56.1 and the guest 192.168.56.10, with a 255.255.255.0 mask on both. Use the actual subnet in your VirtualBox Host-Only configuration - don't assume those example values exist on your machine.

Here's the routing rule people miss: keep the default route on the NAT interface. The Host-Only interface is for reaching the host and anything else on that private subnet. In a typical two-adapter design, it should not have a default gateway. If you add a second default gateway on the Host-Only interface, some traffic may take the "wrong" path and internet access can stop working or become flaky.

Why not use Bridged mode for everything?

Bridged mode isn't inherently "unsafe," and sometimes it's the simplest solution. The trade-off is that the guest sits on your physical LAN like any other device. That can expose services to other LAN users, depending on firewall rules and network policy.

For a throwaway test VM on a trusted home network, that's often fine. For a lab server that only needs internet access and host management, NAT plus Host-Only keeps the guest off the physical LAN while still making day-to-day work easy. The goal isn't "never bridge." It's "don't grant LAN reachability you don't need."

Create NAT and Host-Only connectivity

VirtualBox's UI labels can vary a bit between versions and host operating systems, but the setup is basically the same: create a Host-Only network, attach it to the VM, then configure the guest OS.

Create or check the Host-Only network

In VirtualBox Manager, open the network settings. Depending on your version, Host-Only networks may show up under Tools, Network, or the app's global network preferences.

Create a Host-Only network if you don't already have one. Check the host-side IPv4 address and network mask. For example, VirtualBox may assign the host-side Host-Only adapter 192.168.56.1 with a /24 mask. The guest's Host-Only address must live in the same subnet and must not collide with any other device.

If you want, enable the Host-Only DHCP server so the guest can get an address automatically. DHCP is convenient for short-lived test VMs. For a homelab box you'll SSH into repeatedly, a static Host-Only address is usually simpler. Either way, avoid manually assigning an IP that falls inside the DHCP pool (unless you're intentionally reserving it).

VirtualBox Host-Only network settings showing the host adapter address and network mask

Attach both adapters to the VM

Shut down the VM before changing adapter settings. In the VM's Settings → Network area:

  1. Enable Adapter 1 and set Attached to to NAT.
  2. Enable Adapter 2 and set Attached to to Host-Only Adapter.
  3. Select the Host-Only network you created.
  4. If your VirtualBox version shows that option, make sure "cable connected" (or similar) is enabled for both adapters.

Linux will usually notice the adapters as interfaces like enp0s3 and enp0s8 - but interface numbering depends on the guest OS and virtual hardware. Verify the interface names in the guest instead of copying examples blindly.

VirtualBox VM network settings with NAT on the first adapter and Host-Only on the second

Configure and test a Linux guest

The examples below assume a Linux guest using NetworkManager (common across many distros). Exact interface names and tools vary, but the flow is the same. Start by checking what the guest sees:

ip -br link

ip -br addr

nmcli connection show

Figure out which interface is NAT and which is Host-Only. If you're unsure, compare the guest adapter's MAC address with what you see in VirtualBox's VM network settings. This is especially helpful when the guest has multiple interfaces or when predictable interface naming isn't what you expected.

Configure a static Host-Only address with nmcli

Assume your Host-Only interface is enp0s8, the host-side adapter is 192.168.56.1/24, and you want the guest to use 192.168.56.10. Replace those with your actual subnet and interface name.

Find the NetworkManager connection profile tied to that interface:

nmcli connection show

Then set the static address and remove the default route from this connection:

sudo nmcli connection modify "Wired connection 2" \

ipv4.method manual \

ipv4.addresses 192.168.56.10/24 \

ipv4.gateway "" \

ipv4.never-default yes

Use your real connection profile name instead of "Wired connection 2". Setting ipv4.never-default yes makes it clear this interface is for the Host-Only subnet only - it won't become the guest's internet path.

Apply the change:

sudo nmcli connection down "Wired connection 2"

sudo nmcli connection up "Wired connection 2"

If there's no NetworkManager profile for the Host-Only interface, create one. The connection name and interface name below are examples - adjust them:

sudo nmcli connection add type ethernet \

con-name host-only \

ifname enp0s8 \

ipv4.method manual \

ipv4.addresses 192.168.56.10/24 \

ipv4.never-default yes

You usually don't need to set a gateway or DNS on the Host-Only connection. Let the NAT connection handle the default route and DNS via DHCP. Try not to edit the NAT profile while you're setting up Host-Only unless you have a specific routing requirement.

Configure with nmtui or DHCP

If you prefer a menu-based tool, run:

sudo nmtui

Pick Edit a connection, select the Host-Only profile, and set the IPv4 address and prefix. Leave the gateway blank for the usual two-adapter setup. Save and activate the profile. nmtui is also useful if you need to create the connection interactively.

Alternatively, enable the Host-Only DHCP server in VirtualBox and let the guest use automatic IPv4. That cuts down on manual work, but the guest address can change unless you set a reservation or otherwise make addressing predictable. If you rely on SSH automation or dev tools, double-check the assigned IP after each change.

Verify routes and SSH access

Check the guest's addresses and route table:

ip addr

ip route

You should see a Host-Only address on the second interface, plus a default route pointing out through the NAT interface. Test outbound connectivity from the guest, then test reachability from the host by pinging the guest's Host-Only address. A failed ping doesn't always mean "the network is broken" - ICMP may simply be blocked by the guest firewall. SSH is usually the more meaningful test if that's how you'll manage the VM.

Make sure an SSH server is installed and running. On systemd-based systems:

sudo systemctl status sshd

Some distros use ssh instead of sshd. Allow the SSH service through the guest firewall, then connect from the host:

ssh your-user@192.168.56.10

The host's VirtualBox Host-Only adapter and the guest's Host-Only address should be on the same subnet. Once SSH works, tools like Visual Studio Code Remote SSH or your preferred terminal emulator can use that private IP. If you want more detail on the adapter behavior, see the VirtualBox User Manual.

Troubleshoot and secure the setup

When a VM isn't reachable, don't randomly change five settings at once. Work from the bottom up: confirm the adapter is enabled, confirm the interface exists in the guest, check the IP address, check routes, and only then try the application-level test like SSH.

Common problems

  • No Host-Only interface in the guest: Confirm Adapter 2 is enabled and attached to the correct Host-Only network. Reboot or rescan networking if the guest OS doesn't pick it up cleanly.
  • Host and guest can't reach each other: Make sure both IPs are on the same subnet and that the guest IP isn't duplicated. Host or guest firewalls can also block traffic.
  • SSH times out: Confirm the SSH service is running, port 22 is allowed by the guest firewall, and you're connecting to the Host-Only IP (not an old NAT address).
  • Internet stops after adding the second adapter: Check ip route. The NAT interface should normally own the default route. Remove any unintended default gateway from the Host-Only connection.
  • Address changes after a restart: Your Host-Only interface is using DHCP. Use a static address outside the DHCP pool, or configure a reservation if VirtualBox supports it in your setup.
  • Host-only subnet conflicts with another network: Pick a private subnet that doesn't overlap with your LAN, VPN, or other virtual networks. Overlapping routes can send traffic somewhere you didn't expect.

Keep exposure proportional to the task

NAT plus Host-Only reduces direct exposure to your physical LAN, but it's not a replacement for firewalling or hardening your guest. Keep the guest updated, use SSH keys where it makes sense, and only enable the services you actually need.

Also, don't treat Host-Only as an automatic "secure boundary." A Host-Only network can connect multiple guests (and the host). It's still just a private network - secure it like one.

Use Bridged mode when the VM genuinely needs to behave like a peer on the LAN. For example, if you're testing LAN discovery or access from another physical device. Before you do that, check your network's policies and the guest's firewall. On corporate networks, even a "just for testing" bridged VM can violate policy.

For a small Kubernetes or server lab, NAT plus Host-Only is a solid baseline: outbound access is straightforward, and host management uses a predictable private address. If cluster nodes need to talk to each other, decide whether you also need a shared NAT Network (or another dedicated lab network) rather than relying on a default setup that only fits one node.

Conclusion

For a VM that needs internet access and dependable host management, NAT plus Host-Only is a practical default. NAT handles outbound connectivity; Host-Only gives you a private IP for SSH and development without placing the guest directly on your physical LAN.

The details are simple: use the real subnet from your Host-Only config, keep the default route on NAT, and verify the guest firewall and SSH service. Use Bridged mode only when LAN access is actually a requirement, not because it looks like the easiest "one setting solves everything" answer.

Start with the smallest topology that meets your needs, and add networks only when a specific traffic requirement forces your hand.

Frequently Asked Questions

Yes. Enable two virtual adapters: one attached to NAT for outbound access and another attached to Host-Only for host communication. Keep the NAT interface as the guest’s default route.
Host-Only keeps the VM off the physical LAN by default, reducing unnecessary exposure. It is not a complete security control, so firewall rules and secure guest configuration still matter.
Usually not. The Host-Only adapter reaches the host and private subnet, while the NAT adapter should provide the default route for internet-bound traffic.
Use DHCP when the address does not need to stay predictable. For regular SSH access or scripts, use a static address or DHCP reservation, and avoid conflicts with the DHCP pool.

Related articles