DNS errors occur essentially because you cannot connect to an IP address, which can sometimes freeze your entire server. One such error is “Temporary failure in name resolution” on CentOS servers, where server owners can’t run their applications, perform new installations, and this list continues.
Today I help you resolve such complex DNS errors. For example, when you try to ping a website, you might bump into the error shown:
sumi@ubuntu:~$ ping abc.com
ping: abc.com: Temporary failure in name resolution
It is usually a name resolution error and showing that your DNS server cannot resolve the domain names into their respective IP addresses. It leads you to a grave challenge as you will not be able to update, upgrade, or even install any software packages on your Linux system.
In this article, we have included some causes and solutions of 'temporary failure in name resolution.
1.Missing or Wrongly Configured resolv.conf File
The /etc/resolv.conf file is the resolver configuration file in Linux systems. It contains the DNS entries that help your Linux system to resolve domain names into IP addresses.
If this file is not present or is there but you still have the name resolution error, create one and append the Google public DNS server as shown
nameserver 8.8.8.8
Save the changes and restart the systemd-resolveds service as shown.
$ sudo systemctl restart systemd-resolved.service
It’s also prudent to check the status of the resolver and ensure that it is active and running as expected:
$ sudo systemctl status systemd-resolved.service
Then try pinging any website and the issue should be sorted out.
sumi@ubuntu:~$ ping abc.com
2. Firewall Restrictions
If you cannot resolve the issue using the above solution, firewall restrictions could be preventing you from successfully performing DNS queries. Check your firewall and confirm if port 53 (used for DNS – Domain Name Resolution ) and port 43 (used for whois lookup) are open. If the ports are blocked, open them as follows:
For UFW firewall (Ubuntu / Debian and Mint)
To open ports 53 & 43 on the UFW firewall run the commands below:
$ sudo ufw allow 53/tcp
$ sudo ufw allow 43/tcp
$ sudo ufw reload
For firewalld (RHEL / CentOS / Fedora)
For Redhat based systems such as CentOS, invoke the commands below:
$ sudo firewall-cmd --add-port=53/tcp --permanent
$ sudo firewall-cmd --add-port=43/tcp --permanent
$ sudo firewall-cmd --reload
We hope that now you have an idea about the 'temporary failure in name resolution' error and how you can resolve it in a few simple steps. As always, your feedback is much appreciated.