Over a million developers have joined DZone.

VirtualBox CentOS Second Network Dynamic Host

DZone's Guide to

VirtualBox CentOS Second Network Dynamic Host

Trying, and failing, to connect to the Internet with a CentOS running inside VirtualBox? A few properties tweaks might be your answer.

· Cloud Zone ·
Free Resource

Learn how to migrate and modernize stateless applications and run them in a Kubernetes cluster.

I recently had trouble connecting to the Internet with CentOS running inside the Oracle VM VirtualBox — even though I had configured the second adapter Network Internet Connection to be Host-only Adapter with the name VirtualBox Host-Only Ethernet Adapter. I still had problems pulling any Docker images from scratch. It turned out the network was busted.

$ nslookup bbc.co.uk
Not found
$ ping
Network Unreachable

For the following section, it helps to become the “root” superuser on your CentOS VM. In order to track down the issue, check the current network status.

Outside the Docker container, inside the CentOS VM, issue the following command.

$ ifconfig

You should see “enp0s3” and “enp0s8”, these are the Ethernet connections. “enp0s3” is the first NIC and the second is “enp0s8” — if you don’t see this, then it is down. Actually, you should also see “inet” address that means it is connected to your local LAN.

You need to configure the setup for CentOS, so that when your VM starts, it starts this Ethernet connection.

Edit the /etc/sysconfig/network file. Make sure you add the following:


Ensure that you have a valid DNS name server lookup in your /etc/resolv.conf. Here, I used Google’s services, and you could substitute your own ISPs:


Finally, edit the file /etc/sysconfig/network-scripts/ifcfg-enp0s3 and ensure the connection is up and running.


Make sure the ONBOOT=yes is defined. While you are at this point, check on the script ifcfg-enp0s8 too.

Restart the system services:

$ service networking restart

Afterward, see if the nslookup and previous ping now work for you. Assuming they do, finally, issue a reboot on the VM and try again:

$ shutdown -r now

Join us in exploring application and infrastructure changes required for running scalable, observable, and portable apps on Kubernetes.

cloud ,virtualbox ,centos ,connectivity ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}