How to Configure Network Between Guest VM and Host in Oracle VirtualBox

Once you have installed different operating systems in Oracle VirtualBox, you may want to enable communication between the host and the virtual machines.

In this article, we will describe the simplest and direct method of setting up a network for guest virtual machines and the host in Linux.

For the purpose of this tutorial:

  1. Host Operating System – Linux Mint 18
  2. Virtual Machine OS – CentOS 7 and Ubuntu 16.10


  1. A working Oracle Virtualbox installed on Host machine.
  2. You must have installed a guest operating system such as Ubuntu, Fedora, CentOS, Linux Mint or any of your choice in the Oracle virtual box.
  3. Power off the virtual machines as you perform the configurations up to the step where your required to turn them on.

In order for the guest and host machines to communicate, they need to be on the same network and by default, you can attach up to four network cards to your guest machines.

The default network card (Adapter 1) is normally used to connect the guest machines to the Internet using NAT via the host machine.

Important: Always set the first adapter to communicate with the host and the second adapter to connect to the Internet.

Create a Network For Guests and Host Machine

At the Virtualbox manager interface below, start by creating a network on which the host and guests will operate.

Go to File –> Preferences or hit Ctrl + G:

Virtualbox Preferences Window
Virtualbox Preferences Window

From the following interface, there are two options; choose Host-only Networks by clicking on it. Then use the + sign on the right to add a new host-only network.

Set Guest Network
Set Guest Network

Below is a screen shot showing a new host-only network has been created called vboxnet0.

Virtualbox Preferences Window
Virtualbox Preferences Window

If you want, you can remove it by using the - button in the middle and to view the network details/settings, click on the edit button.

You can as well change the values as per your preferences, such as the network address, network mask, etc.

Note: The IPv4 address in the interface below is the IP address of your host machine.

Host Network Details
Host Network Details

In the next interface, you can configure the DHCP server that is if you want the guest machines to use a dynamic IP address (make sure it is enabled before using it). But I recommend using a static IP address for the virtual machines.

Now click OK on all network settings interfaces below to save the changes.

Set Guest Static IP aAddress
Set Guest Static IP aAddress

Configure Virtual Machine Network Settings

Note: You can follow the steps below for every virtual machine that you want to add on the network to communicate with the host machine.

Back at the virtual box manager interface, select your guest virtual machine such as Ubuntu 16.10 server or CentOS 7 and click on the Settings menu.

Configure VM Settings
Configure VM Settings

Configure Adapter to Connect Virtual Machine to Host

Choose the Network option from the interface above. Afterwards, configure first network card (Adapter 1) with the following settings:

  1. Check the option: “Enable Network Adapter” to turn it on.
  2. In the field Attached to: select Host-only Adapter
  3. Then select the Name of the network: vboxnet0

As in the screen shot below and click OK to save the settings:

Enable Network Adapter for Guest VM
Enable Network Adapter for Guest VM

Configure Adapter to Connect Virtual Machine to Internet

Then add a second network card (Adapter 2) to connect virtual machine to the Internet via the host. Use the settings below:

  1. Check the option: “Enable Network Adapter” to activate it.
  2. In the field Attached to: select NAT
Enable Network Adapter for VM
Enable Network Adapter for VM

Setup Static IP Address for Guest Virtual Machine

At this stage, power on the guest virtual machine, login and configure static IP address. Run the command below to show all the interfaces on the guest machine and allocated IP addresses:

$ ip add
Configure Static IP Address for VM
Configure Static IP Address for VM

From the screen shot above, you can see that there are three interfaces enabled on the virtual machine:

  1. lo – loopback interface
  2. enp0s3 (Adapter 1) – for host-only communication which is using the DHCP as set in one of the previous steps and later configured with a static IP address.
  3. enp0s8 (Adapter 2) – for connection to the Internet. It will use DHCP by default.
On Debian/Ubuntu/Linux Mint

Important: Here, I used Ubuntu 16.10 Server: IP address:

Open the file /etc/network/interfaces using your favorite editor with super user privileges:

$ sudo vi /etc/network/interfaces

Use the following settings for the interface enp0s3 (use your preferred values here):

auto  enp0s3
iface enp0s3 inet static

Save the file and exit.

Then restart network services like so:

$ sudo systemctl restart networking

Alternatively, reboot the system and closely, check if the interface is using the new ip addresses:

$ ip add
On RHEL/CentOS/Fedora

Important: For this section, I used CentOS 7: IP address:

Begin by opening the file for enp0s3 – host-only network interface; /etc/sysconfig/network-scripts/ifcfg-enp0s3 using your favorite editor with super user privileges:

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

Create/modify the following settings (use your preferred values here):

NM_CONTROLLED=no     #use this file not network manager to manage interface

Save the file and exit. Then restart network service as follows (you can as well reboot):

$ sudo systemctl restart network.service 

Check if the interface is using the new IP addresses as follows:

$ ip add

Manage Virtual Machines From Host Using SSH

On the host machine, use SSH to manage your virtual machines. In the following example, am accessing the CentOS 7 ( using SSH:

$ ssh [email protected]
$ who
Connect Guest VM using SSH
Connect Guest VM using SSH

That’s it! In this post, we described a straightforward method of setting up a network between a guest virtual machines and the host. Do share your thoughts about this tutorial using the feedback section below.

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

65 thoughts on “How to Configure Network Between Guest VM and Host in Oracle VirtualBox”

  1. Hi. I want to know what the steps would be for windows 7 when it’s the guest OS, as the command line inputs you are using are invalid for windows of any form. My host OS is Linux mint 20, and the guest OS is Windows 7. My assumption is that the steps are the same for setting up the VM itself, but once you are working inside the VM, obviously the steps will be different even if very similar.

  2. Nice post. It was as very helpful.

    Manage Virtual Machines From Host Using SSH: This portion of the document is not explanatory.

    • @GANIYU

      Oh yes, the purpose of this section was simply to demonstrate how to connect to a VM using its IP address, via SSH once there is a host-only connection established between the VM and the host.

  3. Hi all,

    My friend Vijay just changed the following interfaces

    # vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 & ifcfg-enp0s8

    ONBOOT=No --> ONBOOT=yes

    and restart the machine, I am able to ping and resolve the issue.

  4. Thanks for the great tutorial! But I have an issue, everything works fine for me except when I do a ping from my guest VM to other website on the internet (ex., 100% of the sending packet was loss. I don’t know how to fix this.

    I’m using windows 10 for my host and Ubuntu Server 18.04 for my guest VM.

    I really need your help.
    Thanks in advance.

  5. Fantastic tutorial! It was a little confusing that you just included a link to the tutorial for “configure static IP address”. Also, that tutorial’s screenshots do not match what I saw in CentOS 7. The values are in quotation marks in the screenshots, but there aren’t any quotation marks around the values in my CentOS 7 files.

  6. I found that when I got to add a Host-only adapter to my VM’s Network, I could not select any Name in the dropdown, and the settings were invalid. As mentioned at you need to close the VM’s settings, go to File->Host Network Manager, and create a network there.

    Then, go into the VM’s Network Settings and you can choose the newly created Host Only network there. This may be what the first section in this article “Create a Network For Guests and Host Machine” was trying to do, but the UI has changed so much I found it impossible to follow.

    • Hi Nick,


      Your comment was so apt for the problem I am also having. I also realized you need to work with Host Network Manager first.

  7. Hi Aaron

    I do not see ifcfg-enp0s8 file in network-scripts location and unlike in your screenshots, I have no IP address for enp0s3 & enp0s8 attached but virbr0 has IP. ( Is that default?)

    I wonder which file to update now for static IP configuration to connect from win10 through Putty?

    Looking forward for your help. Thanks

    • @Ravi

      Which distro are you using? Use the appropriate file for your distro, it could be different from what is in the screenshot.

  8. Hello, I have created multiple linux machines on Oracle VM box, it has internal connectivity each other and also have internet access from just one linux machine but unable to access internet from other linux machine. It will be great help if you can suggest to access internet from other machine without disturbing internal connectivity.


Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.