How to network two or more virtual machines using VirtualBox
In this guide, we will give a step-by-step explanation on how to network two or more virtual machines using VirtualBox.
VirtualBox is an open-source software that makes it easy to create virtual machines. It allows users to run multiple operating systems on a single computer, share resources between the host and guest operating systems, create snapshots of virtual machines, and customize the settings to suit their needs. It is portable, free, and open-source, making it a versatile and powerful tool for developers and IT professionals.
Another ability it offers is networking two or more virtual machines. This guide will concentrate on how to network two or ore more virtual machines using VirtualBox. If you follow the steps, you will see that it is actually pretty easy!
How to network two virtual machines using VirtualBox: Network options
First, let's look at all the networking modes VirtualBox offers:
- NAT (Network Address Translation)
- Bridged Mode
- Host-Only Mode
- Internal Mode
- Generic Driver
- NAT Network
- Cloud Mode
NAT (Network Address Translation)
In NAT mode, VirtualBox sets up a private network between the host computer and the virtual machine. The host computer acts as a router, and the virtual machine is assigned an IP address from a pool of addresses managed by VirtualBox. This mode is suitable for most use cases, as it allows the virtual machine to access the internet and the host computer.
"Even though the NAT service separates the VM from the host, the VM has access to the host's loopback interface and the network services running on it. The host's loopback interface is accessible as IP address 10.0.2.2 (assuming the default configuration, in other configurations, it's the respective address in the configured IPv4 or IPv6 network range). This access to the host's loopback interface can be extremely useful in some cases, for example, when running a web application under development in the VM and the database server on the loopback interface on the host," says Oracle.
VirtualBox uses the host computer's physical network adapter to create a bridge between the host and guest operating systems. This mode is useful when you want to give the virtual machine its own IP address on the network and make it accessible to other computers on the same network.
It sets up a private network between the host computer and the virtual machine, but the virtual machines are physically separated from the network. This mode is useful for creating a secure network for testing or development purposes.
It creates a private network between virtual machines and lets them have their own networks. This mode is useful in some aspects, but your VMs won't have internet access.
The chosen VM is given its own network controller and is isolated from the rest of the physical network. It can share the host machine's generic network interface.
It is very similar to the regular NAT mode. The only difference is that it adds virtual machines to the network. In other words, it lets virtual machines use the host's internet connection but on separate networks.
Cloud mode was launched in January 2023 and is still in the preliminary stage, experimental, as Oracle says. Obvious of its name, it lets you use a cloud network to make your local virtual machine available over the internet.
How to network two virtual machines using VirtualBox
Now that you have an idea on networking types, let's move on to the actual steps on how to network two virtual machines using VirtualBox. We assume you have already downloaded VirtualBox and installed it on your PC.
- At the top left of your screen, click File, hover over to Tools, and click Network Manager.
- Click on the NAT Network tab and click on Create (right over the NAT Network tab).
- Make sure the Allow DHCP option is selected, then enter the necessary data here.
- Click on Apply.
- Go to your virtual machine settings.
- Open the Network tab and select NAT Network on the dropdown menu.
- In the Name dropdown section, choose the newly formed NAT network and hit OK to complete the process.
As every VM network mode differs, you might want to read their descriptions and decide which satisfies your needs.
Don't forget to check these guides:
- How to Install MacOS on Windows 10 in a Virtual Machine
- How to install macOS in VirtualBox on Windows 11?
- How to install Windows 11 in VMware Workstation