22

I'm running ubuntu server 16.04.2 and apt-get update returns temporary failure resolving "everything on the list".

  • When I ping www.google.com, it responds with unknown host.
  • When I ping with 8.8.8.8, I get packets sent with no errors etc.

I have tried every "fix" I can find in Ubuntu forums and all over the rest of the internet world and nothing works. The resolv.conf is empty, ifconfig shows nic is functioning, firewall is off, and I threw away the hammer just in case. Unfortunately, I am typing this on another computer on the same network but can't attach text from the various outputs to show whats going on. Need help on this please.

The resolv.conf file contains these lines:

# 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
search 8.8.8.8 8.8.4.4

The last line is placed their by the interfaces file when you reboot the system. This is new for 16.04LTS. I'm thinking Windows NT4 wasn't so bad and neither was Ubuntu Server 12.

7 Answers7

34

You need a Name Server in your /etc/resolv.conf file. Edit your /etc/resolv.conf and add a working Name Server. Google provides a free one, 8.8.8.8.

Do this:

$ nano /etc/resolv.conf

Place this as the first non-commented line:

nameserver 8.8.8.8

You can verify this functionality with:

$ ping -c10 www.google.com

You can make this change permanent by adding the line to this file your /etc/resolvconf/resolv.conf.d/head file.

L. D. James
  • 25,444
6

The marked answer actually doesn't work on Ubuntu 18.04.01. To fix this issue, here's what I did:

  • Execute sudo gedit /usr/lib/systemd/resolv.conf
  • Paste nameserver 8.8.8.8 (and/or any other nameserver(s) you want), then save and exit.
  • Add a symlink by executing sudo ln -sf /usr/lib/systemd/resolv.conf /etc/resolv.conf

Credits to https://askubuntu.com/a/1050280/899241

4

Could you post a link to the page that told you that file resolv.conf should be empty? My guess is that it is misleading at best.

Edit that file with command sudo nano /etc/resolv.conf and put there a single line:

nameserver 8.8.8.8

That should fix your name resolution and the various programs that use it - ping, apt-get, etc.

You also ought to investigate why resolv.conf is empty. Perhaps your DHCP server isn't configured properly.

sмurf
  • 4,750
  • 1
  • 26
  • 30
1

You are facing a problem related to DNS Server that you have specified for you system. Check your nameserver entry in /etc/resolv.conf.

The problem is , ping command is not able to identify what is "www.google.com" because your DNS server is not able to resolve it and provide google actual IP address(every server can only be accessed by its IP address)

Solution

Edit the entry in /etc/resolv.conf. Either provide a correct DNS server of a choice in /etc/resolve.conf that can resolve "www.google.com"

or yYou can specify your local system resolver whose IP address is 127.0.0.53 by adding line

nameserver 127.0.0.53

or provide Google's DNS server IP (any one of them): 8.8.8.8 or 8.8.4.4

nameserver 8.8.8.8**

P.S You can understand better how DNS works here

Pablo Bianchi
  • 17,371
1

I had the same problem, until I edited with the following values the file 50-cloud-init.yaml

 network:
    ethernets:
        eno2:
            addresses:
            - 192.168.0.50/24 (my static ip address)
            dhcp4: false
            gateway4: 192.168.0.42
            nameservers:
                addresses: [208.67.222.222,208.67.220.220]
                search: [208.67.222.222]

hope it works for you too

0

Not an good idea on Ubuntu 16.04.x just overwriting /etc/resolv.conf. The OS will overwrite it for its own most likely.

The file /etc/resolv.conf is usually a symbolic link to another file:

ls -lisa /etc/resolv.conf
1310924 0 lrwxrwxrwx 1 root root 29 Jul 13  2016 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

which means it is correct and you can edit it, but most likely another program is going to overwrite it. I'm going to guess you have NetworkManager installed. To my knowledge this service manages the content of your resolve. So you really should try to setup that one. (On other Hand NetworkManager could be disabled on you system. You might have to tell me.)

Try nmtui and add there the correct DNS Server. I also would use 8.8.8.8 only as secondary DNS. Your primary DNS should be a machine or router nearby your local network or whatever you have there...

-2

The issue we addressed here is one that boiled down to resolving domain names to an ip address internally. Since version 15 of Ubuntu server, i believe, uses a system of dynamic configuration files that change every time the service or system is restarted or rebooted. If the administrator makes a change to resolv.conf file, those changes are deleted when the resolver service is restarted.

To make changes permanent, Ubuntu has made a way to make user changes permanent without affecting the dynamic configuration of the config files. The suggestion from L.D. James (above) was to add the changes I needed to make to the /etc/resolvconf/resolv.conf.d/head file.

This made the changes permanent and solved the problem of resolving domain names error message host not found. It is the solution to setting the dns nameserver in the interfaces file and then getting it to the resolver as well. Thank you all for your supreme efforts in solving this puzzle.