I had recently trouble connecting to the Internet with Centos running inside the Oracle VM VirtualBox. Even though I had configure 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 126.96.36.199 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 of Docker container, inside the Centos VM, issue the following command.
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 192.168.56.107” address that means it is connected to your local LAN.
You need to configure the setup for Centos, so that when your VM starts, if starts this Ethernet connection.
Edit the following file /etc/sysconfig/network
Make sure you add the following
Ensure that you have valid DNS name server look up in your
/etc/resolv.conf. Here, I used Google’s services and you could substitute your own ISPs:
nameserver 188.8.131.52 nameserver 184.108.40.206
Finally, edit the file
/etc/sysconfig/network-scripts/ifcfg-enp0s3 and ensure the connection is up and running.
TYPE="Ethernet" BOOTPROTO=dhcp NAME="enp0s3" ... UUID="17eeb7fe-f11c-4b8b-83be-a9dd2281dda2" DEVICE="enp0s3" ONBOOT="yes"
Make sure the
ONBOOT=yes is defined. While you are at this point, check on script
Restart the system services:
$ service networking restart
Afterwards, see if the nslookup and ping previous now work for you.
Finally, issue a reboot on VM and try again
$ shutdown -r now