How to get Connected Two Virtual Machines In VirtualBox

If you ever need to run multiple OSes simultaneously, a virtual machine (VM) is one of your best options. It’s cost-effective, provides relatively good performance, and with thousands of free resources available on the internet, is relatively easy to set up regardless of your expertise with VMs and hypervisors.

But what if you want to network two or more VMs? Luckily, VirtualBox has you covered with plenty of networking options for all sorts of different setups that can be configured in a few simple clicks.

How Does Networking Between Multiple VMs Work?

Networking multiple VMs is actually quite similar to how you would network multiple real computers on a real network. However, VirtualBox has as many as eight networking modes for all sorts of different needs that you might have.

Here’s a quick overview of all the different networking modes you get in VirtualBox.

  • Not attached: This mode simply disconnects the VM from the rest of your network, meaning it’ll have no network and, by extension, internet connectivity with the host or any other virtual machines.
  • Generic Driver: This network mode lets you share the generic network interface of your host machine with the selected VM, meaning the particular VM gets its own network controller and is separated from the rest of the physical network. You can then install drivers for the generic network interface using an extension pack, but they’re often included with VirtualBox anyway.
  • NAT: Network address translation (NAT) sets up a dedicated network between the host machine and the specific VM for which you select this mode. It’s an isolated network, meaning no other machine other than the host and the specified VM can talk to each other. The VM can also use the host’s internet connection in this network mode.
  • NAT Network: This is similar to a NAT but adds all the VMs you created in VirtualBox to the network instead. This means that the host machine and all your VMs are on an isolated network where they can communicate with each other and use the host machine’s internet connection to connect to the internet.
  • Bridged Adaptor: Under this setting, each VM is treated as a separate machine on your actual network, meaning the host machines, any VMs you might have and any other devices on your network can talk to each other without any hassles. Of course, this also means that your VMs get access to the internet.
  • Host-only Adapter: Under this setting, your VMs and the host machine are all connected but are physically cut off from the rest of your network. This provides the highest level of network security for your VMs, with the trade-off being rather limited networking capabilities. This setting might also be called Host-only Network on some older versions of VirtualBox.
  • Internal Network: This sets up an internal network between multiple VMs. In this mode, the VMs are separated even from the host machine and are on a network of their own. Keep in mind that this is the only network mode in VirtualBox where your VMs don’t have internet access.
  • Cloud Network: This is an experimental VirtualBox network mode that launched with VirtualBox 7.0.6 in January 2023 that allows a local VM to connect to a subnet on a remote cloud service to make it accessible over the internet, among other enterprise use cases.

You might’ve noticed some of these network modes are similar on the surface, especially the NAT, Bridge, and Host-only network modes. However, keep in mind that while these might look similar, they have small differences and nuances in terms of overall connectivity and network capabilities.

Which Virtual Machine Network Mode Should You Choose?

The specific network mode you choose will largely depend on what your requirements are from your VM network. If you’re just looking to make your VMs accessible over your local network, Bridged Adaptor will work wonderfully well as it requires no additional setup and will instantly make your VMs accessible from any device on your network.

On the other hand, if you’ve got multiple other devices on your network and need something more secure, setting up a NAT Network or using Host-only Adaptor is the more sensible choice. If you want airtight security between your VMs or need to set up an air-gapped network for a penetration testing scenario, an Internal Network is the way to go.

We recommend starting with the Bridged Adaptor mode and then moving on to any of the other networking modes based on your specific requirements.

How to Network Two Virtual Machines Using Virtual Box

As you can probably guess by now, networking two VMs is just a matter of selecting the right network mode per your specific requirements in the VM settings and setting up the VM as you would a real machine.

Here’s how you can quickly set up your VMs for networking using the NAT Network mode.

  1. Open the VirtualBox Network Manager by heading to File > Tools > Network Manager. Alternatively, you can also use the Ctrl + H keyboard shortcut.
  2. Open the NAT Network tab, then click Create at the top to create a new network. Fill out the required information here, such as the network name and IPv4 prefix, and ensure the Enable DHCP option is checked.
  3. Click the Apply button to save your network.
  4. Now head over to your VM settings, click the Network tab, and in the Attached to dropdown, select NAT Network.
  5. Select the NAT network we just created in the Name dropdown.
  6. Click OK to save your settings.

Repeat steps four to six for as many VMs as you want on your NAT network, and you’re good to go. The next time you boot any of these VMs, or if they’re already booted up, you’ll be connected to this new NAT network and can communicate with other VMs on the same network.

Networking Is Easy With VirtualBox

Networking multiple VMs can be very easy once you get to grips with all the different networking options that VirtualBox provides. Setting the virtual network up is also a matter of a few clicks.