systemd-resolved is a system service that provides network name resolution to local applications. It implements a caching and validating DNS/DNSSEC stub resolver, as well as an LLMNR resolver and responder. In addition it maintains the /run/systemd/resolve/resolv.conf file for compatibility with traditional Linux programs. This file may be symlinked from /etc/resolv.conf.
The glibc NSS module nss-resolve(8) is required to permit glibc's NSS resolver functions to resolve host names via systemd-resolved.
The DNS servers contacted are determined from the global settings in /etc/systemd/resolved.conf, the per-link static settings in /etc/systemd/network/*.network files, and the per-link dynamic settings received over DHCP. See resolved.conf(5) and systemd.network(5) for details. To improve compatibility, /etc/resolv.conf is read in order to discover configured system DNS servers, but only if it is not a symlink to /run/systemd/resolve/resolv.conf (see above).
systemd-resolved synthesizes DNS RRs for the following cases:
- • The local, configured hostname is resolved to all locally configured IP addresses ordered by their scope, or --- if none are configured --- the IPv4 address 127.0.0.2 (which is on the local loopback) and the IPv6 address ::1 (which is the local host).
- • The hostnames "localhost" and "localhost.localdomain" (as well as any hostname ending in ".localhost" or ".localhost.localdomain") are resolved to the IP addresses 127.0.0.1 and ::1.
- • The hostname "gateway" is resolved to all current default routing gateway addresses, ordered by their metric. This assigns a stable hostname to the current gateway, useful for referencing it independently of the current network configuration state.
- • The mappings defined in /etc/hosts are resolved to their configured addresses and back.
Lookup requests are routed to the available DNS servers and LLMNR interfaces according to the following rules:
- • Lookups for the special hostname "localhost" are never routed to the network. (A few other, special domains are handled the same way.)
- • Single-label names are routed to all local interfaces capable of IP multicasting, using the LLMNR protocol. Lookups for IPv4 addresses are only sent via LLMNR on IPv4, and lookups for IPv6 addresses are only sent via LLMNR on IPv6. Lookups for the locally configured host name and the "gateway" host name are never routed to LLMNR.
- • Multi-label names are routed to all local interfaces that have a DNS sever configured, plus the globally configured DNS server if there is one. Address lookups from the link-local address range are never routed to DNS.
If lookups are routed to multiple interfaces, the first successful response is returned (thus effectively merging the lookup zones on all matching interfaces). If the lookup failed on all interfaces, the last failing response is returned.
Routing of lookups may be influenced by configuring per-interface domain names. See systemd.network(5) for details. Lookups for a hostname ending in one of the per-interface domains are exclusively routed to the matching interfaces.
Note that /run/systemd/resolve/resolv.conf should not be used directly by applications, but only through a symlink from /etc/resolv.conf.
See the m[blue]resolved D-Bus API Documentationm for information about the APIs systemd-resolved provides.
- Upon reception of the SIGUSR1 process signal systemd-resolved will dump the contents of all DNS resource record caches it maintains into the system logs.
- Upon reception of the SIGUSR2 process signal systemd-resolved will flush all caches it maintains. Note that it should normally not be necessary to request this explicitly - except for debugging purposes - as systemd-resolved flushes the caches automatically anyway any time the host's network configuration changes.
resolved D-Bus API Documentation