Virtualbox is a very popular hypervisor which allows you to run guest virtual machines like Windows, Linux, BSD, Solaris etc.
For various purposes you might want to combine several virtual machines into one network.
In this post I’ll describe the easiest way of how to do that, which is good enough for most of the cases, end secure at the same time.
I assume that Adapter 1 is configured as NAT (this is default value when you create a new virtual machine).
First you need to open Oracle VM VirtualBox Manager, and then click on:
File –> Preferences –> Network –> click on the + to add a new NAT Network.

You can add a Network name, IP address range, DHCP, port forwarding etc.
It is enough to fill only fields that you can see on the figure below.

Now that I’ve created a new NAT network, we need to add it to all VM’s that will be part of the same network LAN.
You only need to add Adapter 2 for selected VM’s inside Oracle VM VirtualBox Manager like on the following figure.

Last step is to start selected VM, and check if everything is working as expected.
For example on Ubuntu 18.04 LTS network is properly applied which can be seen after you run the following comands:
nmcli con show
NAME UUID TYPE DEVICE
Wired connection 1 a9s6ddd7-b70c-3a00-7839-aq7861a8a209 ethernet enp0s3
Wired connection 2 36d4142e-e9c6-915a-aadd-33f5c87bf5fd ethernet enp0s8
If you cannot see two network adapters, you can run the following command:
nmcli con up enp0s8
To auto start a new network interface, you can execute the following:
nmcli con modify enp0s3 connection.autoconnect yes
Unfortunately that was not a case for OEL (Oracle Linux), where I first need to add a new network adapter by using Network Manager GUI (or by using command line in case you are running VM with no GUI).
In case of GUI, you just need to click on:
Applications–> System Tools –> Settings Network–>Add NAT Network
Network Name: Lab1
Network CIDR: 172.25.1.0/24
Support DHCP: Enabled
or you can check the following figures of how to do it.




Summary:
By adding a NAT network, all VM’s with added adapter will be able to communicate with each other.
Below you can find some of the benefits after completion of described network configuration:
- Configured network is more secure comparing with some other configurations, as communication from host to VM is disabled (unless you don’t have Port forwarding in place), while communication from VM to host is not possible.
- It’s easy to set up NAT network as you don’t need to know much about networking (which is not true for some more complex networking types), although OS sysadmin knowledge is required.
- For most of applications this type of network configuration is satisfactory (only for some special cases like Oracle RAC, it’s inappropriate).
Setting up VirtualBox VM’s networking opens up a new horizon for setting up WebLogic clustering, installing enterprise applications, testing distributed computing etc, that I’ll explore in some future posts.
Comments