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

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

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.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

54 Responses

  1. Tidywolf says:

    In the configuration file for the host only adapter why is it necessary to include gateway and dns server entries? Aren’t these only required for communication with outside of the local network?

  2. Mark Chassy says:

    I have all of the above working now, but I can’t hit the webserver which is running on the guest, from the host.

    I get:

    (venv27)==> curl
    curl: (7) Failed to connect to port 8080: Connection refused
  3. Mark Chassy says:

    Really clear, but a couple questions/comments:

    1. Is there a reason to set the host only network as the first adapter and the NAT as the second. On Ubuntu, it does not seem to make a difference, but on CENTOS/RHEL it does.

    On VirtualBox, the NAT is usually there by default, so one naturally puts the host only second. If you try to switch the host only to static when the adapters are in that that order, the NAT seems to break.

    If you leave both as dynamic and switch the NAT to second place, the onboot=yes switches to onboot=no.

    You have to change that manually.

    Then you can switch the host-only to static and everything works fine.

    • Aaron Kili says:


      There is actually no difference, you can leave NAT for connecting to the internet on adapter 1 and add a second adapter for host-only connection. And thanks for sharing these useful tips.

      • Mark Chassy says:

        Yes, now that I have deactivated the firewall, I realize that I lost half a day just because of that and that I had my adapters set up correctly before. At least now, I actually understand what I am doing.

  4. Rinart73 says:

    And after going through all these instructions I still can’t access nginx server that is running on VirtualBox from my host PC. It just gets stuck on connecting. I guess Windows 10 just can’t do it properly.

  5. Richard says:

    Great article.

    But I have a problem. I want to configure an IP on the virtualbox Centos6.9 instance as follows: Its default IP is

    My own network on my pc is which is hosting the VirtualBox software has the IP

    I am try and on the Centos6.9 VB IP to and try and restart the network and it says Ok but the IP is not changed its still

    • Aaron Kili says:


      Take not that you need to enable two network interfaces for your guest; one will be used to connect to the internet which should have the IP address by default and another for host-only connection which will probably have the IP address

      Follow the steps at the start of the article carefully for this to work i.e create a network for create a for guests and host machine, then add the necessary network interfaces as explained above.

      Also note this article is based on CentOS 7.

  6. george says:

    If dhcp is enabled in host, why to use a static ip in guest, i think iface enp0s3 inet dhcp works better than static

  7. JT says:

    After making adapter 1 host-only and adapter 2 NAT, when I try to start up my VM it gets stuck on “Start job is running for Wait for Network to be Configured” and eventually says that its failed.

    So I end up with no internet. Any idea how to fix this?

    • Aaron Kili says:


      Then login to your system and configure static IPs as explained in the article, either for Debian/Ubuntu/Linux Mint or RHEL/CentOS/Fedora systems. Then restart the system for the changes to take effect.

  8. Anand Doraiswamy says:

    This is by far the best detailed documentation on this topic. I have been searching on how to setup n/w between guest hosts with static IP on my Virtualbox. Nothing even came close. Thanks a million. Awesome!

  9. Surren says:

    Very quick, simple and succinct. Well done.

  10. Lucas says:

    Very good, thanks :)

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.