How To Resolve Ubuntu Virtualbox Network Is Unreachable Error

My host machine OS is windows 10, and i install oracle virtual box on it. The guest OS in virtual box virtual machine is Ubuntu 18.04.1. I use the Ubuntu OS normally for example code development. But one day when i start the Ubuntu virtual machine, i find the network do not work correctly.

I can not access network, the error message is ubuntu connection failed, activation of network connection failed, i can not ping domain name (for example .com) the error message is Name or service not known, even i can not ping the ip address of the domain, the error message is network is unreachable. I struggled for all these error for almost several hours, finally i resolve this problem follow below steps.

1. Enable Network Connection To Fix Activation Of Network Connection Failed.

If you encounter network issue in Linux OS such as Ubuntu, the first thing you need to do is to check whether your network configuration is correct or not.

  1. Open a terminal and run below command.
    ~$ ifconfig
    enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet netmask broadcast
  2. If you can not find the inet address in the console output, this means the network is not enabled correctly. You need follow below steps to enable the network first.
  3. Click Show Applications —> Settings icon to open Ubuntu configuration panel. Click Network menu item in left panel. Then toggle Wired button to ON in right panel. Now run $ifconfig command in terminal again, you should find the ip address that DHCP server assigned to you.
    disable ubuntu global network proxy settings

2. Fix Name Or Service Not Known Issue.

After configurations in step 1, you should get your virtual machine ip address, and you can also ping other ip address in your local network or internet website, but you may find you can not ping domain name. When you ping a domain name you get error message like below.

~$ ping
ping: Name or service not known

When you turn on / off wired network in step 1. Below DNS record will be written to /etc/resolve.conf, and the DNS record is invalid. This lead to Name or service not know error when you ping website domain in terminal. And this DNS record is generated by the NetworkManager automatically.

# Generated by NetworkManager

To resolve this problem, just run $ sudo gedit /etc/resolve.conf to change the nameserver ip to a valid one such as ( google provide ). Then save resolve.conf file now you can ping domain successfully.

3. Fix Invalid DNS Record nameserver Permanently.

After step 1 and step 2, you can ping domain name now. To avoid this error happen again, you can remove the invalid DNS record  and add valid DNS record permanently in /etc/resolve.conf when you reboot the OS again.

  1. Run below command to install Ubuntu resolvconf package.
    $ sudo apt install resolvconf
  2. Modify file /etc/resolvconf/resolv.conf.d/tail and add a valid DNS record ( such as nameserver ) in it. If the tail file do not exist then create it.
    $ sudo gedit /etc/resolvconf/resolv.conf.d/tail
  3. Now when you boot the Ubuntu OS, the DNS record ( nameserver in the tail file will be added at the end of file /run/resolvconf/resolv.conf, and /etc/resolv.conf will be a symbol link to this file.
0 0 votes
Article Rating
Notify of

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

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x