Blog Home
Updated: 2023 May 29

The Sisyphean Task Of DNS Client Config on Linux

Configuring DNS client settings on Linux can sometimes feel like a Sisyphean task, but with a proper understanding of the process, it becomes more manageable. Here are a few key points to keep in mind:

  1. DNS Resolvers: Linux uses a resolver library, typically GNU C Library (glibc), to handle DNS queries. The resolver reads the `/etc/resolv.conf` file to determine the DNS servers to use.
  2. `/etc/resolv.conf`: This file contains the configuration for DNS resolution. It specifies the IP addresses of DNS servers to query and other options. However, some Linux distributions generate this file dynamically, making manual edits ineffective.
  3. Network Manager: Many modern Linux distributions use Network Manager, a service that manages network connections. Network Manager often takes control of DNS configuration, overriding manual changes made to `/etc/resolv.conf`. Instead, it relies on its own configuration files located in `/etc/NetworkManager/`.
  4. systemd-resolved: Systemd-resolved is another service commonly used on Linux systems. It provides DNS caching and resolves DNS queries. It may take precedence over manual `/etc/resolv.conf` edits. Its configuration can be found in `/etc/systemd/resolved.conf`.

Considering these factors, here are some general steps to configure DNS on Linux:

  1. Check the DNS configuration files: Look into `/etc/resolv.conf`, `/etc/NetworkManager/NetworkManager.conf`, and `/etc/systemd/resolved.conf`. Determine which service is managing DNS.
  2. Network Manager Configuration: If Network Manager controls DNS, modify its configuration files. For example, you can add DNS servers to the `[main]` section of `/etc/NetworkManager/NetworkManager.conf`.
  3. systemd-resolved Configuration: If systemd-resolved handles DNS, modify its configuration file (`/etc/systemd/resolved.conf`). Update the `DNS=` line to include the desired DNS servers.
  4. Restart Services: After making changes, restart the relevant services to apply the new DNS settings. For example, restart Network Manager with `sudo systemctl restart NetworkManager`.

Remember that different Linux distributions may have variations in their network configuration tools, so it's essential to consult your specific distribution's documentation for accurate instructions.

While DNS configuration on Linux can be complex, understanding the relevant components and following the appropriate steps should help you achieve the desired DNS client configuration.

This post is generated by gpt.


Email questions, comments, and corrections to

Submissions may appear publicly on this website, unless requested otherwise in your email.