38

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?
8
  • Well, if /run/resolvconf/resolv.conf doesn't exist there is no point in creating a symlink from /etc/resolv.conf to it. So until you found out why that file doesn't exist I would recommend to use your working, manual resolv.conf. Can you add the output of dpkg -l resolvconf to your question? Jun 10, 2018 at 12:15
  • Did you configure netplan to use your chosen DNS client, as described here? Name Resolution Jun 10, 2018 at 12:16
  • 1
    The resolvconf program doesn't appear to be installed; if I type 'dpkg -l resolvconf' I get 'un resolvconf <none> <none> (no description available)
    – coxe87b
    Jun 11, 2018 at 12:53
  • Yes, I tried configuring netplan with DNS to no avail
    – coxe87b
    Jun 11, 2018 at 12:56
  • 1
    This resolved this error for me. ycsoftware.net/…
    – user946871
    Apr 20, 2019 at 15:24

5 Answers 5

20

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.

2
10

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.

2
  • I've just upgraded from 16 to 18 but there's nothing in /etc/netplan. Jul 9, 2020 at 7:37
  • @DanDascalescu It's hard to say if You have netplan installed after upgrading. Try this one askubuntu.com/questions/1034711/…
    – R1NZU
    Jul 14, 2020 at 11:50
2

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

0

I had the same name resolution issue after upgrading to Ubuntu 18.04 LTS.

Cause:

Upgrading the system had wiped the DNS name server settings that were previously in /etc/resolv.conf

Solution:

Edit /etc/resolvconf/resolv.conf.d/base and add the name server details

nano /etc/resolvconf/resolv.conf.d/base

Add the IP address of your DNS name server for your network or ISP in this format:

nameserver 12.34.56.78

(Replace the ip address 12.34.56.78 with your DNS name server. )

To have the changes take effect immediately run:

sudo resolvconf -u

The last line lets you skip rebooting. Alternatively you can also edit /etc/resolv.conf and make the exact same changes (but this file will be rewritten on reboot).

Don't know your DNS name server?

Go to a windows machine on the same network, and from the command prompt type

ipconfig /all

If you have several devices then each device should have a DNS name server listed and you will want to pick accordingly. The DNS server info will look like this :

DNS Servers . . . . . . . . . . . : 12.34.56.78
0

There can be multiple reasons behind this, but the most common one is that your DNS server is not able to look up the ip address conrrosponding to the domain name you are entering.

  1. what you can do is to check your configuration file located in here:

    sudo nano /etc/resolv.conf

if there is nameserver specified there, so there is no problem. but if not, you can manually add one nameserver to it. some common nameservers that are owned by google are :

8.8.8.8
4.4.4.4

so all you need to do is to add them like this, to your configuration file:

nameserver 8.8.8.8

or

nameserver 8.8.4.4

or

nameserver <IP_Address_for_DNS_Server>

then restart the network setting and try to ping some website:

sudo systemctl restart systemd-resolved.service
ping google.com
  1. if the problem still exists there might be a permission error of this file. this is what you can do : change the ownership of the file using:

    sudo chown root:root /etc/resolv.conf

now change the file permissions :

sudo chmod 644 /etc/resolv.conf

now you can check again using:

ping google.com
  1. another possibility is that your firewall is blocking you to access from some ports. this is what i suggest you to do:

    sudo ufw allow 43/tcp sudo ufw allow 53/tcp if firewall not enabled :

    sudo ufw enable

then you should reload so that changes can be applied.

sudo ufw reload

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .