Configuring Linux DNS
Configuring DNS (Domain Name System) on Linux can be complex due to the various ways it can be set up.
In this context, Tailscale is a service that aims to work alongside the existing DNS configuration on a Linux system.
However, some configurations may not be fully compatible with Tailscale's cooperative management of the host's DNS settings.
Here's a detailed explanation of the two common problems mentioned:
NetworkManager + systemd-resolved
NetworkManager is a service that manages network connections on many Linux distributions.
systemd-resolved is a system service that provides network name resolution to local applications.
In distributions that use both NetworkManager and systemd-resolved, it's important to ensure that the
/etc/resolv.conf
file is a symbolic link (symlink) pointing to/run/systemd/resolve/stub-resolv.conf
.The
/etc/resolv.conf
file is a configuration file that specifies the DNS servers and search domains used by the system for name resolution.By default,
/etc/resolv.conf
should be a symlink to/run/systemd/resolve/stub-resolv.conf
. If it's not, you can create the symlink manually using the command:
When NetworkManager detects the presence of this symlink, it assumes that systemd-resolved is being used for DNS resolution and avoids overwriting the
resolv.conf
file.After fixing the symlink, it's recommended to restart the relevant services to ensure the changes take effect:
DHCP dhclient overwriting /etc/resolv.conf
/etc/resolv.conf
In the absence of a DNS management system, DHCP clients like
dhclient
and programs liketailscaled
have no choice but to directly modify the/etc/resolv.conf
file.DHCP (Dynamic Host Configuration Protocol) is a network protocol that automatically assigns IP addresses and other network configuration parameters to devices on a network.
When a DHCP client like
dhclient
obtains network configuration from a DHCP server, it may overwrite the/etc/resolv.conf
file with the DNS servers provided by the DHCP server.Similarly,
tailscaled
, the Tailscale daemon, may also attempt to modify the/etc/resolv.conf
file to configure its own DNS settings.If both
dhclient
andtailscaled
are modifying theresolv.conf
file independently, it can lead to conflicts and loss of functionality. For example, a DHCP renewal may overwrite theresolv.conf
file, causing the loss of Tailscale's MagicDNS functionality.
To address these issues, it's recommended to use a centralised DNS management system that can handle the coordination between different components.
By using a compatible DNS management system, such as systemd-resolved or dnsmasq, you can ensure that the DNS configuration is managed consistently and avoid conflicts between different programs modifying the /etc/resolv.conf
file directly.
It's important to note that the specific steps and configurations may vary depending on the Linux distribution and the DNS management system being used.
It's always a good idea to refer to the documentation and guidelines provided by your distribution and the respective services to ensure proper configuration and compatibility.
Last updated
Was this helpful?