How to set permanent DNS nameservers in Linux

Linux School Tech
3 min readAug 4, 2024

--

/etc/systemd/resolved.conf is a configuration file for systemd-resolved, a service that provides network name resolution to local applications. This service is part of the systemd suite of utilities used in many Linux distributions for managing system services and resources.

Purpose of systemd-resolved

systemd-resolved offers several features:

  • DNS Resolution: It can resolve domain names via various DNS servers.
  • LLMNR and mDNS: It can support Link-Local Multicast Name Resolution (LLMNR) and Multicast DNS (mDNS).
  • DNSSEC Support: It can provide additional security for DNS resolutions using DNSSEC.

Configuration Options

The /etc/systemd/resolved.conf file allows users or system administrators to modify the behavior of systemd-resolved. Here are some commonly configurable options found in this file:

[Resolve] Section

  • DNS=: Specifies the DNS servers to be used for resolution.
  • FallbackDNS=: Specifies fallback DNS servers if the primary ones fail.
  • Domains=: Defines search domains for DNS resolution.
  • LLMNR=: Configures whether to enable or disable LLMNR (can be yes, no, or resolve).
  • MulticastDNS=: Configures whether to enable or disable mDNS (can be yes or no).
  • DNSSEC=: Enables or disables DNSSEC validation (values can be no, allow-insecure, or strict).

How to set DNS addresses permanently in /etc/systemd/resolved.conf file?

Why do you need permanent DNS?

Permanent DNS in a Linux system is crucial for various network-related operations. If your system does not have a properly configured DNS (Domain Name System), several issues can arise, which can affect package management, connectivity, and the ability to use network services effectively. Here are some of the common issues related to DNS not being set up properly:

ping: unknown host <hostname>

Utilities like ping rely on DNS to convert hostnames to IP addresses. If the DNS is misconfigured, you might see errors like:

ping: unknown host <hostname>

This means the system was unable to resolve the hostname to an IP address, making it impossible to establish a connection.

curl: (6) Could not resolve host: <hostname>

Commands like curl or wget that require resolving URLs will also fail if DNS is not set up properly. You might see errors such as:

curl: (6) Could not resolve host: <hostname>

This indicates that the tool was unable to translate the given hostname into an IP address.

Temporary failure in name resolution

This is an error message that indicates a system’s inability to resolve a domain name to an IP address at a given moment. This often occurs due to issues with DNS (Domain Name System) configuration, network connectivity problems, or unresponsive DNS servers.

In practical terms, it means that the system cannot reach the server that translates domain names (like example.com) into numerical IP addresses, which is necessary for accessing websites or services. If this error appears, it may require troubleshooting steps such as checking network connections, verifying DNS settings, or testing alternative DNS servers.

--

--