Temporary failure in name resolution

Let’s break down the process of fixing the “Temporary failure in name resolution” error by modifying the /etc/resolv.conf file and restarting the systemd-resolved service.

Understanding the Problem: “Temporary failure in name resolution”

This error indicates that your system cannot translate domain names (like [geçersiz URL kaldırıldı]) into IP addresses (like 172.217.160.142). This translation is the job of the Domain Name System (DNS). When your system can’t reach a DNS server or there’s a problem with the DNS configuration, you encounter this error, preventing you from accessing websites and other network resources by name.

The Solution: Modifying /etc/resolv.conf and Restarting systemd-resolved

  1. /etc/resolv.conf – The DNS Configuration File: This file contains the DNS settings for your system. The most important setting here is nameserver, which specifies the IP address of a DNS server.

  2. Adding Google Public DNS Servers: By adding nameserver 8.8.8.8 and nameserver 8.8.4.4 to /etc/resolv.conf, you’re instructing your system to use Google Public DNS servers. These are reliable and widely available DNS servers.

    • 8.8.8.8: Google Public DNS primary server.
    • 8.8.4.4: Google Public DNS secondary server.
  3. The nano Command: sudo nano /etc/resolv.conf opens the /etc/resolv.conf file in the nano text editor with root privileges (required to modify system files).

  4. Restarting systemd-resolved: sudo systemctl restart systemd-resolved.service restarts the systemd-resolved service. This service is responsible for resolving domain names on systems using systemd (which is most modern Linux distributions). Restarting it ensures that the changes you made to /etc/resolv.conf are applied.

Step-by-step Instructions:

  1. Open your terminal.

  2. Edit the /etc/resolv.conf file:

    Bash

    sudo nano /etc/resolv.conf
    
  3. Add the following lines at the end of the file:

    nameserver 8.8.8.8
    nameserver 8.8.4.4
    

    If there are other nameserver lines in this file, adding these lines below them will prioritize Google’s DNS servers.

  4. Save the file (in nano, press Ctrl+X, then Y, then Enter).

  5. Restart the systemd-resolved service:

    Bash

    sudo systemctl restart systemd-resolved.service
    
  6. Test your internet connection by trying to access a website.

Important Note: On many modern Linux systems that use systemd-resolved, directly editing /etc/resolv.conf is not the recommended long-term solution. The file is often dynamically generated. Changes made directly to this file may be overwritten on reboot or network changes.

A More Permanent Solution (using resolved.conf):

A better approach is to modify /etc/systemd/resolved.conf and then restart the service.

  1. Edit /etc/systemd/resolved.conf:
    Bash

    sudo nano /etc/systemd/resolved.conf
    
  2. Uncomment (remove the #) and change the DNS= lines to:
    DNS=8.8.8.8 8.8.4.4
    #FallbackDNS=
    
  3. Restart the systemd-resolved service:
    Bash

    sudo systemctl restart systemd-resolved.service
    

This method ensures that your DNS settings persist across reboots.