← All articles
Ubuntu · VirtualBox · Networking

Providing Internet and Host Access to a VirtualBox Guest

A development VM may need two different kinds of connectivity at the same time: outbound internet access and a private path back to the host computer. In the VirtualBox setup used for this article, that was achieved with two network adapters.

The related article Accessing a VirtualBox Guest Service from the Host covers the host-only side in more detail.

Version context: This configuration reflects VirtualBox and Ubuntu networking from 2017. Interface names, Linux network configuration files, and VirtualBox options have changed across releases, so verify the current networking model before applying these steps to a modern VM.

Configure Two Network Adapters

With the virtual machine shut down:

  1. Open Settings → Network.
  2. Enable Adapter 1 and attach it to NAT. This adapter provides outbound connectivity through the host.
  3. Enable Adapter 2 and attach it to a Host-only Adapter. This provides a private network between the host and guest.
  4. Review any advanced adapter settings required by the environment.
  5. Start the virtual machine.

Identify the Guest Interfaces

The original Ubuntu environment used:

ls /sys/class/net/

The VM exposed two network interfaces in addition to loopback. The original example used enp0s3 and enp0s8.

The guest network configuration was then updated in /etc/network/interfaces for that Ubuntu version:

After updating the configuration, the VM was rebooted and internet connectivity was tested.

Why Two Adapters Work

The two interfaces have separate responsibilities. NAT provides outbound connectivity without directly exposing the guest to the physical network, while the host-only interface provides predictable host-to-guest communication for local services.

Troubleshooting

If internet access still fails, inspect the guest's routes, DNS configuration, interface state, and DHCP assignments rather than assuming the VirtualBox adapter selection alone is sufficient. On modern Ubuntu versions, network configuration may be managed by Netplan or NetworkManager instead of /etc/network/interfaces.

Takeaway

Separating external connectivity from host-only development traffic produces a clearer local networking model. It also makes troubleshooting easier because each interface has a defined purpose.

CONTINUE READING

Explore closely related architecture, integration and implementation topics.