systemd-resolved

systemd-resolved is a systemd service that provides network name resolution to local applications via a D-Bus interface, the resolve NSS service (nss-resolve(8)), and a local DNS stub listener on 127.0.0.53. See systemd-resolved(8) for the usage.

Installation

systemd-resolved is a part of the systemd package that is installed by default.

Configuration

systemd-resolved provides resolver services for Domain Name System (DNS) (including DNSSEC and DNS over TLS), Multicast DNS (mDNS) and Link-Local Multicast Name Resolution (LLMNR).

The resolver can be configured by editing and/or drop-in .conf files in . See .

To use systemd-resolved start and enable .

Tip: To understand the context around the choices and switches, one can turn on detailed debug information for systemd-resolved as described in systemd#Diagnosing a service.

DNS

Software that relies on glibc's getaddrinfo(3) (or similar) will work out of the box, since, by default, is configured to use nss-resolve(8) if it is available.

To provide domain name resolution for software that reads directly, such as web browsers and GnuPG, systemd-resolved has four different modes for handling the file—stub, static, uplink and foreign. They are described in . We will focus here only on the recommended mode, i.e. the stub mode which uses .

contains the local stub 127.0.0.53 as the only DNS server and a list of search domains. This is the recommended mode of operation that propagates the systemd-resolved managed configuration to all clients. To use it, replace  with a symbolic link to it:
# ln -rsf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
Automatically

systemd-resolved will work out of the box with a network manager using . No particular configuration is required since systemd-resolved will be detected by following the symlink. This is going to be the case with systemd-networkd, NetworkManager, and iwd.

However, if the DHCP and VPN clients use the resolvconf program to set name servers and search domains (see openresolv#Users for a list of software that use resolvconf), the additional package is needed to provide the symlink.

Note:
Manually

In stub and static modes, custom DNS server(s) can be set in the file:

/etc/systemd/resolved.conf.d/dns_servers.conf
[Resolve]
DNS=192.168.35.1 fd7b:d0bd:7a6e::1
Domains=~.
Fallback

If systemd-resolved does not receive DNS server addresses from the network manager and no DNS servers are configured manually then systemd-resolved falls back to the fallback DNS addresses to ensure that DNS resolution always works.

The addresses can be changed by setting in . E.g.:

To disable the fallback DNS functionality set the option without specifying any addresses:

DNSSEC

DNSSEC validation can be enabled by changing setting in .

  • Set to validate DNSSEC only if the upstream DNS server supports it.
  • Set to always validate DNSSEC, thus breaking DNS resolution with name servers that do not support it. For example:
/etc/systemd/resolved.conf.d/dnssec.conf
[Resolve]
DNSSEC=true

Test DNSSEC validation by querying a domain with a invalid signature:

$ resolvectl query sigfail.verteiltesysteme.net
sigfail.verteiltesysteme.net: resolve call failed: DNSSEC validation failed: invalid

Now test a domain with valid signature:

DNS over TLS

DNS over TLS is disabled by default. To enable it change the setting in the section in . To enable validation of your DNS provider's server certificate, include their hostname in the setting in the format . For example:

can be used to test if DNS over TLS is working since DNS over TLS always uses port 853 and never port 53. The command ngrep port 53 should produce no output when a hostname is resolved with DNS over TLS and  should produce encrypted output.

Wireshark can be used for more detailed packet inspection of DNS over TLS queries.

mDNS

systemd-resolved is capable of working as a multicast DNS resolver and responder.

The resolver provides hostname resolution using a "hostname.local" naming scheme.

mDNS will only be activated for a connection if both systemd-resolved's mDNS support has been enabled, and if the configuration for the currently active network manager enables mDNS for the connection.

systemd-resolved's mDNS support can be enabled by its setting (see resolved.conf(5) §OPTIONS).

Enabling per-connection mDNS support depends on the network manager:

  • For systemd-networkd, set the setting in the section of a per-connection settings file. You may also have to set in the section. See .
  • Otherwise, for NetworkManager, set in the section of the connection's settings file. Running will do that for you. See nm-settings(5).

LLMNR

Link-Local Multicast Name Resolution is a hostname resolution protocol created by Microsoft.

LLMNR will only be activated for the connection if both the systemd-resolved's global setting ( in resolved.conf(5) §OPTIONS) and the network manager's per-connection setting is enabled. By default systemd-resolved enables LLMNR responder; systemd-networkd and NetworkManager enable it for connections.

Tip: The default for all NetworkManager connections can be set by creating a configuration file in /etc/NetworkManager/conf.d/ and setting connection.llmnr in the [connection] section. See NetworkManager.conf(5) §CONNECTION SECTION.

If you plan to use LLMNR and use a firewall, make sure to open UDP and TCP ports .

Lookup

To query DNS records, mDNS or LLMNR hosts you can use the resolvectl utility.

For example, to query a DNS record:

Troubleshooting

systemd-resolved not searching the local domain

systemd-resolved may not search the local domain when given just the hostname, even when or Domains=[domain-list] is present in the appropriate systemd-networkd's .network file, and that file produces the expected in . You can run or to check if the search domains are actually being picked up.

Possible workarounds:

  • Disable LLMNR to let systemd-resolved immediately continue with appending the DNS suffixes
  • Trim 's database (e.g., by removing option after resolve service)
  • Switch to using fully-qualified domain names
  • Use /etc/hosts to resolve hostnames
  • Fall back to using glibc's instead of using systemd's resolve

systemd-resolved does not resolve hostnames without suffix

To make systemd-resolved resolve hostnames that are not fully qualified domain names, add to .

This only seems to work with LLMNR disabled (LLMNR=no).

If you are using systemd-networkd, you might want the domain supplied by the DHCP server or IPv6 Router Advertisement to be used as a search domain. This is disabled by default, to enable it add to the interface's .network file:

You can check what systemd-resolved has for each interface with:

$ resolvectl domain
gollark: I don't have a link or anything.
gollark: No, I mean can I have the *renderer* for wallpaperous purposes only?
gollark: Also, can I have this for wallpaperous purposes only?
gollark: π/τ, insufficiently dodecahedral.
gollark: Yes, but these are cooler.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.