Временная ошибка при разрешении linux

Sometimes when you try to ping a website, update a system or perform any task that requires an active internet connection, you may get the error message ‘temporary failure in name resolution’ on your terminal.

For example, when you try to ping a website, you might bump into the error shown:

tecmint@ubuntu:~$ ping google.com
ping: tecmint.com: Temporary failure in name resolution

This is usually a name resolution error and shows that your DNS server cannot resolve the domain names into their respective IP addresses. This can present 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 will look at some of the causes of the ‘temporary failure in name resolution‘ error and solutions to this issue.

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 resolve domain names into IP addresses.

If this file is not present or is there but you are still having the name resolution error, create or open the /etc/resolv.conf file in a text editor with root privileges.

$ sudo nano /etc/resolv.conf
OR
$ sudo vim /etc/resolv.conf

Next, add Google’s public DNS servers with the nameserver keyword followed by the IP address of the DNS server.

nameserver 8.8.8.8
nameserver 8.8.4.4

Add DNS Name Servers

Add DNS Name Servers

Save the changes and restart the systemd-resolved 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.

$ ping google.com

Check Network Connection in Linux

Check Network Connection in Linux

After confirming your network connection, make sure to edit the /etc/resolv.conf file to prevent it from being overwritten by network management tools.

To do this, you can create a symbolic link to /dev/null:

$ sudo ln -sf /dev/null /etc/resolv.conf

Note: Some Linux distributions, especially those using NetworkManager, may automatically manage the /etc/resolv.conf file. If that’s the case, manually editing the file might not have a lasting effect.

Instead, you may need to configure DNS settings through the appropriate network management tool or configuration files for your specific distribution. Be sure to consult your distribution’s documentation or support resources for the recommended method of configuring DNS in such cases.

2. Firewall Restrictions

If the first solution did not work for you, 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:

Open DNS Ports on UFW Firewall

On Debian-based distributions, you need to open ports 53 & 43 on the UFW firewall by running the commands below:

$ sudo ufw allow 53/tcp
$ sudo ufw allow 43/tcp
$ sudo ufw reload

Open DNS Ports on FirewallD Firewall

On RHEL-based distributions, you need to open ports 53 & 43 on the Firewalld firewall by running the commands below.

$ sudo firewall-cmd --add-port=53/tcp --permanent
$ sudo firewall-cmd --add-port=43/tcp --permanent
$ sudo firewall-cmd --reload

It’s our hope that you now have an idea about the ‘temporary failure in name resolution‘ error and how you can go about fixing it in a few simple steps. As always, your feedback is much appreciated.

A temporary failure in name resolution is a common issue that Linux users may encounter when their system cannot resolve a hostname to an IP address. This problem can occur due to various reasons, such as network connectivity issues, DNS configuration problems, or issues with the local hosts file. In this article, we will discuss several steps you can take to troubleshoot and resolve this issue on your Linux system.

1. Check your internet connection

Before diving into the technical aspects of resolving the issue, it is crucial to ensure that your system is connected to the internet and that the network is functioning properly. Verify your system’s network connection by attempting to access a website or using the ping command to check the connectivity to a known IP address or domain.

Try to ping an IP address eg: 8.8.8.8 and see the results:

ping 8.8.8.8 -c 4 

If the ping is successful, that means internet is working properly on your system.

2. Verify DNS settings

The first step in troubleshooting temporary failure in name resolution is to verify your system’s DNS settings. The /etc/resolv.conf file contains the DNS server IP addresses, which are usually provided by your Internet Service Provider (ISP) or network administrator. This is the most common error we encouding for this error.

To view the contents of the /etc/resolv.conf file, run the following command:

cat /etc/resolv.conf 

If the file is empty or does not contain valid DNS server IP addresses, you can add them manually. To edit the file, run:

sudo nano /etc/resolv.conf 

Add the following lines with the appropriate DNS server IP addresses, such as Google’s public DNS servers:

nameserver 8.8.8.8

nameserver 8.8.4.4

Save and exit the file using Ctrl+X, then Y, and finally Enter.

3. Check the local hosts file

The /etc/hosts file contains hostname and IP address mappings for your local system. Ensure that this file has the correct entries for your system’s hostname and IP address. You can view the file using:

cat /etc/hosts 

If the file is incorrect or missing entries, edit it using:

sudo nano /etc/hosts 

Add or correct entries as needed, following this format:

127.0.0.1   localhost

192.168.1.100 local.example.com

<yoursystemip>        <yourhostname>

Save and exit the file.

4. Restart the network service

After making changes to the DNS or hosts files, you need to restart the networking service to apply the changes. Run one of the following commands, depending on your Linux distribution:

sudo systemctl restart networking 

or

sudo /etc/init.d/networking restart 

5. Clear the DNS cache

If your system uses a DNS caching service like nscd or dnsmasq, you should clear the cache to ensure that the latest DNS information is used. Run the appropriate command to restart the service:

sudo systemctl restart nscd 

For dnsmasq:

sudo systemctl restart dnsmasq 

6. Test the name resolution

After completing the above steps, test the name resolution using the ping, host, or nslookup commands:

ping example.com 
host example.com 
nslookup example.com 

If the issue persists after following these steps, you may need to consult your network administrator or ISP for further assistance.

Conclusion

Resolving a temporary failure in name resolution on Linux systems involves checking network connectivity, verifying DNS settings, inspecting the local hosts file, restarting network services, and clearing the DNS cache. By following the steps outlined in this article, you should be able to troubleshoot and resolve most cases of temporary failure in name resolution. However, if the issue persists, it is essential to seek help from your network administrator or ISP, as there may be underlying problems with the network infrastructure or configuration that need to be addressed.

In some cases, the issue may also be related to firewall settings or security software on your system that is blocking DNS requests. Make sure to check your firewall rules and security software settings to ensure that they are not interfering with your system’s ability to resolve hostnames.

Furthermore, it is important to keep your system updated and ensure that all packages, including DNS-related tools and services, are up to date. Regularly updating your system can help prevent issues related to outdated or incompatible software components.

By following these steps and maintaining a healthy system, you can minimize the occurrence of temporary failures in name resolution and ensure smooth operation of your Linux system on the network.

Introduction

The «Temporary failure in name resolution» error occurs when the system cannot translate a website name into an IP address. While the error sometimes appears due to a lost internet connection, there are multiple reasons why it may show up on your system.

This tutorial will guide you through troubleshooting and fixing the «Temporary failure in name resolution» error.

How to resolve the "Temporary failure in name resolution" error

Prerequisites

  • Sudo or root privileges
  • A working internet connection

The error appears when a user attempts to communicate with a website using a command such as ping:

ping phoenixnap.com

The system cannot communicate with the DNS server and returns the error.

Pinging a website unsuccessfully.

The most common cause of this error are the resolv.conf network configuration file and a misconfigured firewall. The steps to fix the error in both cases are given below.

Method 1: Badly Configured resolv.conf File

resolv.conf is a file for configuring DNS servers on Linux systems.

To start, open the file in a text editor such as nano.

sudo nano /etc/resolv.conf

Make sure the resolv.conf file contains at least one nameserver. The lines listing nameservers should look like this:

nameserver 8.8.8.8

If you do not have a nameserver listed in the file, add at least one. 8.8.8.8 and 8.8.4.4 are the popular nameservers owned by Google, but you can add any functional DNS server to this list.

The /etc/resolv.conf file in nano editor.

Save the file and exit.

Then, restart the DNS resolver service.

sudo systemctl restart systemd-resolved.service

If successful, the command above returns no output. Test that your new nameservers are correctly configured by pinging a website:

ping phoenixnap.com

If you see the ping command transmitting and receiving data, your DNS server is working properly.

Successfully pinging a website.

Misconfigured Permissions

If your resolv.conf file contains valid DNS servers, but the error persists, it may be due to misconfigured file permissions. Change ownership of the file to the root user with the following command:

sudo chown root:root /etc/resolv.conf

Modify the user permissions to allow everybody on the system to read the file:

sudo chmod 644 /etc/resolv.conf

Ping a website again.

ping phoenixnap.com

If wrong file permissions caused the error, the commands above successfully resolve it.

Method 2: Firewall Restrictions

Another reason for the «Temporary failure in name resolution» error may be a firewall blocking one or both of the following ports:

  • port 43, used for whois lookup
  • port 53, used for domain name resolution

Open the ports in UFW Firewall

Type the following command to allow traffic on port 43 using UFW firewall:

sudo ufw allow 43/tcp

UFW confirms the rule is successfully updated.

Allowing port 43 in UFW.

Repeat the command for port 53.

sudo ufw allow 53/tcp

Reload UFW with the following command:

sudo ufw reload

The output confirms the operation was successful.

Reloading UFW firewall.

Open the ports in firewalld

Some Linux distributions such as CentOS use firewalld as their default firewall. The syntax to open port 43 in firewalld is:

sudo firewall-cmd --add-port=43/tcp --permanent

firewalld outputs the word success.

Allowing port 43 in firewalld.

Repeat the command for port 53.

sudo firewall-cmd --add-port=53/tcp --permanent

Reload the firewall.

sudo firewall-cmd --reload
Reloading firewalld firewall.

Test the connection by pinging a website.

ping phoenixnap.com

Conclusion

This article provided ways to troubleshoot and fix the «Temporary failure in name resolution» error on Linux. To learn more about diagnosing DNS-related problems, read How to Use Linux dig Command.

Encountering the “Temporary failure in name resolution” error shows that Linux systems cannot translate a website name into IP address. While a lost internet connection may be a reason, there are several other factors that could cause this error. This tutorial is presented to help you troubleshoot and resolve this error.

Prerequisites

To proceed with the solutions outlined below, ensure you have sudo or root privileges and a functional internet connection.

  • User must have sudo or root privileges
  • Stable and working network connectivity

When we access a website, our system browser sends a request to a DNS server that will translate the domain name into an IP address. This IP address will connect the website’s server and load the content. If the DNS server fails to provide the IP address, the “Temporary failure in name resolution” error message appears.

For example, if we ping the website from a system, you may experience the following error:

Here the system failed to connect to the DNS server hence resulting in error.

The main three main reason why this error occur includes:

  1. Slow or No Internet Connection
  2. Badly Configured resolv.conf File
    • Misconfigured resolv.conf File Permissions
  3. Firewall Restrictions
    • Open the Ports in UFW Firewall

Solution 1: Slow or No Internet Connection

The first solution to resolve the error is straightforward as the user can check the internet connectivity on the system. If the internet is slow or not connected, you may experience this error.

Solution 2: Badly Configured resolv.conf File

The resolv.conf file sets up the DNS servers on Linux. Open the resolv configuration file in nano editor:

sudo nano /etc/resolv.conf

Make sure at least one nameserver is present inside the resolv.conf file. The nameserver looks like this:

Here in our case nameserver is:

If no nameserver is present in the system. Defined any of the nameservers. Some of the well-known name servers owned by Google are 8.8.8.8 and 8.8.4.4. By editing the resolv.conf file any of the nameserver can be defined.

Save the file and restart DNS service:

sudo systemctl restart systemd-resolved.service

If the DNS server is restarted successfully no output will be returned.

You can also verify the DNS server by again pinging a website:

If communication is established with the website this means the DNS server is now working.

2.1. Misconfigured resolv.conf File Permissions

In some cases, despite the proper DNS server defined inside the resolv.conf file, the error persists. This may be due to file permission missing. Change the ownership access to root user by running the given command:

sudo chown root:root /etc/resolv.conf

Run given command to give permission to each user to allow them to modify the resolv.conf file:

sudo chmod 644 /etc/resolv.conf

Now we will again ping the website.

If the error is due to wrong permission, the above commands will solve it.

Solution 3: Firewall Restrictions

Another reason for the “Temporary failure in name resolution” error is due to a firewall blocking access to the necessary ports, which includes port 43 used for whois lookup and port 53 used for domain name resolution.

3.1. Open the Ports in UFW Firewall

If the error is caused by blocking of port 43, run the below given command to allows traffic on this port:

The Uncomplicated Firewall (UFW) confirms that rules have been successfully updated.

Similarly, we can also allow the permission for port 53 using:

Note: Sometime our UFW firewall is not enabled by default, so to enable it, use:

Now, reload the UFW firewall to apply the changes:

Conclusion

The error “Temporary failure in name resolution” can occur due to no internet connection, missing DNS nameserver or resolv.conf file permissions or firewall restriction. Main solution to this problem is to fix the internet problem, allow the resolv.conf file access to all users or unblock the UFW firewall protection at port 43 and port 53.

About the author

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.

I am getting the following error from ubuntu 20.04 terminal, connected via wired ethernet connection:
When I type the following command which I am using in a bash script:

ping -c 1 google.com

for a health check to ensure it has access, I get the following error:

ping: google.com: Temporary failure in name resolution

Some background

I overwrote my older gaming rig to be a ubuntu multi purpose server (including smart home automation) in my home network. It used to be windows 10, but I formatted the drive and installed ubuntu on it.

I have not yet been able to access the internet with ubuntu, however, I do know that the equipment works because I left the internet wired in, I actually downloaded ubuntu via that machine onto the usb before installing.

Now I cannot see or connect to the ubuntu server from other devices and cannot reach the internet to download even basic tools like netstat.

At this point, I feel like I’ve bashed my head against a wall and scoured the internet (and lots of other stack overflow threads) and tried a bunch of things that didn’t work.

Any help would be greatly appreciated!

Edit: As requested in comments, I am attaching a screenshot, since I am not able access the computer via any network. Only via hdmi.

enter image description here

Edit 2: Second screenshot as requested.

enter image description here

Понравилась статья? Поделить с друзьями:
  • Временная ошибка при разрешении mirror yandex ru
  • Все были поражены его мужеством ошибка
  • Врожденные ошибки иммунитета
  • Все было выполнено согласно приказу найдите грамматическую ошибку
  • Время пролетело вспять наша встреча ошибка песня