DEV Community

Web Decode
Web Decode

Posted on

How to solve No DNS / "Temporary failure in name resolution" error.

If there is no DNS, the system will throw a Temporary failure in name resolution error, meaning that the system has no ideea how to resolve domain names like "google.com" to an IP address.

There are two ways of fixing this kind of error:

Temporary fix

The system uses a special file located in /etc/resolv.conf to resolve domain names. With this in mind, we can add the following entry: nameserver 8.8.8.8 in /etc/resolv.conf.

What this does is that it just tells the system to use the 8.8.8.8 Google DNS when doing DNS lookup.

Permanent fix:

The system normally uses the systemd-resolved service to resolve DNS lookups.
This service uses its own configuration file that is linked with the /etc/resolv.conf file to handle DNS lookups. It also uses a loopback address: 127.0.0.53 to tell the system to send DNS lookup requests to this port and then pick them up.

The systemd-resolved service acts as a local DNS server that has cache, anti-DNS spoofing protection and more. Normally, it contains some entry like nameserver 127.0.0.53. This tells the system to go to 127.0.0.53 when doing DNS lookup. It is the same machine, but on port 53. That is where the systemd-resolved service listens, picks up the request, looks in the local DNS cache and the forwards it upstream to another DNS such as 8.8.8.8.

What may have happened:

  1. Broken configuration link
  2. Down loopback address (in rare cases)

1. Broken configuration link

Normally, there should be a link from /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf. This link might be broken, so we can try to fix it by running the following command:

sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
Enter fullscreen mode Exit fullscreen mode

2. Loopback address is down

If a loopback(lo) address is down, it can’t be used. The systemd-resolved service needs the 127.0.0.53 loopback address to receive requests for DNS lookups.

We can check the status of all lo by using the following command:

ip addr show lo
Enter fullscreen mode Exit fullscreen mode

If 127.0.0.53 is not there, add it by running this command:

sudo ip addr add 127.0.0.53/32 dev lo
Enter fullscreen mode Exit fullscreen mode

Restart the systemd-resolved service

The service has to be restarted by using the following command:

sudo systemctl restart systemd-resolved
Enter fullscreen mode Exit fullscreen mode

Top comments (0)