Ubuntu 16.04 LTS, internet connection doesn't work, but network still can access machine

32,567

Solution 1

It's my understanding that /etc/resolv.conf is for public nameservers only. It appears that yours has been modified to use a private nameserver ostensibly over a VPN. If you wish your Ubuntu box to obtain Domain Name Service normally to allow internet access, I suggest that you revert back to the default /etc/resolv.conf file which contains:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1

You can revert back to the default /etc/resolv.conf file by either restoring the original from a recent backup from before it was modified, or opening the file the link points to with the command sudo gedit /etc/resolv.conf and pasting the code from the default file above into it overwriting it's current content. You may want to save a copy of the current content beforehand as a backup somewhere you will be able to locate it if you find you need it.

NOTE: /etc/resolv.conf is a symbolic link to the file /run/resolvconf/resolv.conf so file based operations such as editing on /etc/resolv.conf will actually be carried out on /run/resolvconf/resolv.conf

To confirm that the link hasn't been erroneously modified run the command ls -l /etc/resolv.conf which should result in the output below.

lrwxrwxrwx 1 root root 29 Feb 25 2016 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

the arrow indicates it's a symlink.

For more information on resolvconf which modifies this file see the man page.

Solution 2

If you have an unmodifed /etc/resolv.conf file (and you should) you should change System Settings -> Network -> Options to be set as shown below so that your router will provide DNS services to your Ubuntu box as it does to your other systems.

DHCP

An alternative is to use Google public DNS service and add 8.8.8.8 and 8.8.4.4 as your DNS servers.

Share:
32,567

Related videos on Youtube

D. Dieks
Author by

D. Dieks

Updated on September 18, 2022

Comments

  • D. Dieks
    D. Dieks over 1 year

    Last night the machine was working fine. This morning, no internet access.

    I'm working with a wired Ethernet connection.
    I can ping the router, but not google.
    I am able to access shared files on the machine from another computer through the wired network.

    Other machines on the network can access the internet. It's only the Ubuntu box that can't get internet.

    I can ping google by address but not by name.

    output of lsb_release -a

    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 16.04.2 LTS
    Release: 16.04
    Codename: xenial

    nmcli dev show | grep DNS partial results:

    IP4.DNS[1]: 192.168.0.1

    Which is the router address.

    `
    more /etc/resolve results:

     # Generated by OpenVPN Client UP Script  
    
     nameserver 10.8.0.1
    

    ls -1 /etc/resolv.conf results:

    -rw-r--r-- 1 root root 172 Feb 23 22:34 /etc/resolv.conf

  • D. Dieks
    D. Dieks about 7 years
    Switched over to settings as shown above. No change. Still can't get internet access.
  • Elder Geek
    Elder Geek about 7 years
    Please edit the output of more /etc/resolv.conf into your post Thank you for helping us help you!
  • D. Dieks
    D. Dieks about 7 years
    When I try to create the symbolic link using ln -s /run/resolvconf/resolv.conf /etc/resolv.conf, I get: ln: failed to create symbolic link '/etc/resolv.conf': File exists
  • D. Dieks
    D. Dieks about 7 years
    OK, you've lost me now. Can you give me more detail on what I should be doing? You'll have to remove the file you created after deleting the link to recreate it makes no sense to me.
  • D. Dieks
    D. Dieks about 7 years
    I didn't delete /etc/resolv.conf. I edited it as per your directions.
  • Elder Geek
    Elder Geek about 7 years
    Well, something modified it inappropriately. See my updated answer.
  • D. Dieks
    D. Dieks about 7 years
    Got it. Done & fixed.
  • Elder Geek
    Elder Geek about 7 years
    Excellent. I'm glad we got it sorted! :-)
  • anshuman
    anshuman about 5 years
    This answer fixed my issue too. In my case the /etc/resolv.conf does not have nameserver 127.0.1.1.