Ubuntu Server 18.04 Temporary failure in name resolution

I have just installed Ubuntu Server 18.04 and set up SSH so I can continue configuring via my desktop but I've run into some issues that I can't seem to get past.

I was trying to run

sudo apt-get update

but was constantly getting the errors:

Temporary failure resolving archive.ubuntu.com

Failed to fetch http://archive.ubuntu........

I checked to see if my internet connection was ok by running

ping 8.8.8.8

and I got a response, all ok there.

I suspected that maybe my DNS was not set-up correctly so I tried

ping www.google.com

and got the error:

Temporary failure in name resolution

Ok, so I had determined that it is, in fact, some sort of DNS issue, but all the “answers” I've tried have not worked for me.

I've tried editing /etc/resolv.conf without luck as it appears to be a symbolic link.

I found an answer here which only works if I run from root, ie:

sudo bash

But it instructs to reverse the changes afterwards by:

rm /etc/resolv.conf
ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

If I do that though, I lose connection again.

  • Should I just leave it the way I had it or something else?
  • Can this be a permanent solution?
  • And is the cause of the problem the fact that /run/resolvconf/resolv.conf doesn't actually exist?

In ubuntu server 18-04, with xorg lightdm lightdm-gtk-greeter and xfce4 GUI installed, when booting into the system, the only way I figured out to get the wired network going is this:

    sudo dhclient -v -4

works great, however, this has to be done manually after every boot and after every network disconnect/reconnect, so it works but it is a manual solution, not the permanent solution;

to get the wireless network going automatically, simply:

    sudo apt-get install nm-tray network-manager

you probably have to reboot; then you will be able to use the wireless network icon that appears in the notification area in your control panel (make sure the notification area is added to the panel) to select a wireless network; after that, it will reconnect automatically;

however, to get the wired network to reconnect automatically, I tried installing avahi-daemon and avahi-autoipd but apparently, it is not helping; even tried:

    sudo systemctl start NetworkManager
    sudo systemctl enable NetworkManager

basically, if you install a distro such as Xubuntu desktop, the proper tool(s)/daemon/config is installed and the network is detected automatically when it is plugged in without any user configuration; would be nice to know which tool/daemon/config/setting does that.


18.04 release change the resolv.conf to netplan

do

man netplan

dir location /etc/netplan inside you will find file eg.: 50-cloud-init.yaml

edit it like this:

network:
    ethernets:
        ens160:
            addresses:
            - 10.10.10.100/24
            dhcp4: false
            gateway4: 10.10.10.1
            nameservers:
                addresses:
                - 8.8.4.4
                - 8.8.8.8
                search:
                - domain.local
    version: 2

when you save file do

sudo netplan apply

and check if u can ping google.com.


I got this error when I was a debootstrap QEMU image.

The resolution required the following:

  1. make the root filesystem rw, or elsedhclient fails. The better way to do this is to add to your /etc/fstab, which is just a dummy in debootstrap:

    /dev/sda / ext4 errors=remount-ro,acl 0 1
    
    • On Ubuntu 18.04, you can do either of the following:

      1. Create a systemd unit that initializes networking at the right time:

        cat << EOF | sudo tee "/etc/systemd/system/dhclient.service"
        [Unit]
        Description=DHCP Client
        Documentation=man:dhclient(8)
        Wants=network.target
        Before=network.target
        
        [Service]
        Type=forking
        PIDFile=/var/run/dhclient.pid
        ExecStart=/sbin/dhclient -4 -q
        
        [Install]
        WantedBy=multi-user.target
        EOF
        
        sudo ln -sf "/etc/systemd/system/dhclient.service" \
            "/etc/systemd/system/multi-user.target.wants/dhclient.service"
        

      Based on: https://gist.github.com/corvax19/6230283#gistcomment-1940694

      1. Use network-manager. Downloads a lot of graphical libraries, but feels less hacky:

        sudo apt-get install network-manager
        cat << EOF | sudo tee "/etc/netplan/01-network-manager-all.yaml"
        # Let NetworkManager manage all devices on this system
        network:
          version: 2
          renderer: NetworkManager
        EOF
        

        I found this by first looking at the first network config file I knew from Debian from my host:

        cat /etc/network/interfaces
        

        but awesome Ubuntu devs left a message there:

         # ifupdown has been replaced by netplan(5) on this system.  See
         # /etc/netplan for current configuration.
         # To re-enable ifupdown on this system, you can run:
         #    sudo apt install ifupdown
        

        so I did a:

        cat /etc/network/interfaces
        

        on my Ubuntu host and found the missing config.

      Full Ubuntu debootstrap setup at: Is there any prebuilt QEMU Ubuntu image(32bit) online?

    • On Debian 9, add the correct entry to your /etc/network/interfaces config file. Mine was:

      auto enp0s3
      iface enp0s3 inet dhcp
      

      and eth0 instead of enp0s3 is another common value, you can find it out with:

      ip link show
      

      Full Debian debootstrap setup at https://unix.stackexchange.com/questions/275429/creating-bootable-debian-image-with-debootstrap/473256#473256