How to configure different types of network in Oracle Virtualbox (Linux)

There are multiple types of network which can be configured in Oracle VirtualBox, so before going ahead you must be clear on your requirement. Here let me give you a brief overview of the type of network which you can create for you set of Linux box using Oracle Virtual Box and then you can choose the best option suiting your requirement.

Please follow below videos to get the graphical representation of the steps which are explained in this article

Network Address Translation (NAT)

NAT provides a one-to-one translation of IP addresses, A virtual machine with NAT enabled acts much like a real computer that connects to the Internet through a router. The "router", in this case, is the VirtualBox networking engine, which maps traffic from and to the virtual machine transparently. In VirtualBox this router is placed between each virtual machine and the host. This separation maximises security since by default virtual machines cannot talk to each other.

Below table demonstrates the type of network which will be created using this option

Questions

Response

Can vm connect to host?

YES

Can host connect to vm?

NO

Can vm connect to external network

YES

Can vm connect another vms in the same network?

NO

Can other computers on the host network connect vm?

NO

Go to the "Settings" of your vm using the steps below

Next select "Network" from the left TAB menu and select "NAT" from the drop down menu for your Network Adaptor as shown below.

NAT Network

This is one additional option you can find in the Oracle VirtualBox which brings in an enhancement to the NAT option already available wherein you can configure a local DHCP server using the Virtual Box which will just assign an internal IP, using which you can connect to the external network as well as the host machine.

Below table demonstrates the type of network which will be created using this option

Questions

Response

Can vm connect to host?

YES

Can host connect to vm?

NO

Can vm connect to external network

YES

Can vm connect another vms in the same network?

YES

Can other computers on the host network connect vm?

NO

Before starting to use NAT Network make sure the pre-requisite config is in place. Go to "File" and select "Preferences" as shown below

Under "Network" TAB select "NAT Networks" and add a new network using the "plus" sign as shown below, for me I have created a network "MyLab" with below values

Provide the Network Name and the subnet details which you want to assign to your vms configured with NAT Network, Click OK to save and exit your configuration.

Bridged network

With bridged networking, VirtualBox uses a device driver on your host system that filters data from your physical network adapter. This driver is therefore called a "net filter" driver. This allows VirtualBox to intercept data from the physical network and inject data into it, effectively creating a new network interface in software. When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable: the host can send data to the guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.

Below table demonstrates the type of network which will be created using this option

you will get direct access to the virtual machine from your host machine

The VM can access external network via host network since the connection is bridged

You can create multiple vms, each with bridged Network and they all can talk to each other over TCP protocol.

Navigate to the Network Setting of your VM using the below steps

Select "Bridged Adaptor" from the drop down menu under "Network" for your Network Adaptor. Also make sure you have selected the correct interface (which you want to be mapped the virtual NIC interface) under "Name"

IMPORTANT NOTE: But this may fail if your host machine is hiding behind a VPN, in such case your internal network will work as it is but you will not be allowed to connect to external network i.e. Internet. For such situations you need a combo of NAT + Bridged Network. Create an additional interface in your vm and configure it with NAT, that should do the magic for you so with NAT you will connect external network while with Bridged Network you can access your vm using ssh client like Putty for ease of use.

Internal Network

Even though technically, everything that can be done using internal networking can also be done using bridged networking, there are security advantages with internal networking. In bridged networking mode, all traffic goes through a physical interface of the host system. It is therefore possible to attach a packet sniffer (such as Wireshark) to the host interface and log all traffic that goes over it. If, for any reason, you prefer two or more VMs on the same machine to communicate privately, hiding their data from both the host system and the user, bridged networking therefore is not an option.

Below table demonstrates the type of network which will be created using this option

Select "Internal Network" from the drop down menu under "Network" for your Network Adaptor. Next add your Internal Network name as created in above step on the Windows CLI, for me I have replaced default "intnet" with "mylab" and click "OK"

Ping statistics for 10.10.10.4: Packets: Sent = 3, Received = 0, Lost = 3 (100% loss), Control-C ^C
No the vm is not reachable which is quite expected.

Host Only Networking

It can be thought of as a hybrid between the bridged and internal networking modes: as with bridged networking, the virtual machines can talk to each other and the host as if they were connected through a physical Ethernet switch. Similarly, as with internal networking however, a physical networking interface need not be present, and the virtual machines cannot talk to the world outside the host since they are not connected to a physical networking interface.

So with Host Only Networking your multiple vms can connect to each other and the same would be reachable via your host machine but the vms would not be able to access the outside external network.

Below table demonstrates the type of network which will be created using this option

Questions

Response

Can vm connect to host?

NO

Can host connect to vm?

YES

Can vm connect to external network

NO

Can vm connect another vms in the same network?

YES

Can other computers on the host network connect vm?

YES

To be able to use Host Only Network option, make sure you have create a subnet with DHCP server. Navigate to "Preferences" under "File"

Under "Network" navigate to "Host Only Networks" and create a new Adapter (if not existing already). For me I am using the default Network Adapter with below subnet details

Next assign the Host Only Network config for your vm using the Network Settings as shown below

Get Articles delivered to your mail

CONNECT US ON SOCIAL PLATFORM

YOU MIGHT ALSO LIKE

RECENT POSTS

Your browser does not support JavaScript!

About Me

My name is Deepak Prasad and I am very passionate about my work which mostly includes and revolves around Linux/Unix platform, virtualisation, openstack cloud, hardware, firmware, security, network, scripting, automation and similar stuff.

If I look back it looks like it was just yesterday when I started as a fresher in my first company as a total noob (which still I am BTW) and now I am here trying to run a tutorial site, I am not sure how good this is but at least I feel I learn something new every time I open my blog to write a new post. This honestly was sort of a notebook for me later turned into a tutorial blog.