systemd-resolved

On this page 7

systemd-resolved is the system service for network name resolution that ships with systemd and is enabled by default on Ubuntu, Fedora and many other distributions. In Linux networking it acts as a local caching stub resolver: applications send their lookups to it, and it forwards them to the right upstream DNS servers, validates and caches the answers and returns them.

Beyond classic unicast DNS, the service also handles LLMNR and multicast DNS, optional DNSSEC validation and DNS over TLS. Its most important feature for administrators is per-link DNS configuration, which allows different interfaces, such as a VPN tunnel and a home Wi-Fi link, to use different DNS servers for different domains.

How systemd-resolved resolves names

systemd-resolved receives queries through three interfaces and answers all of them from the same cache and configuration. Native clients use the D-Bus API or the nss-resolve module in /etc/nsswitch.conf, while legacy software that reads resolv.conf talks to a stub listener on 127.0.0.53, port 53.

When a query arrives, the service selects the most specific matching link based on its routing domains, sends the query to that link’s servers and stores the answer in a positive and negative cache that respects record TTLs. Since systemd 253 a second listener on 127.0.0.54 runs in proxy mode, passing queries upstream without the local synthesis and LLMNR logic.

The table below summarizes the ways a program can reach the service and what each path provides.

InterfaceUsed byCapabilities
D-Bus APIresolvectl, NetworkManagerFull feature set, per-link data
nss-resolveglibc getaddrinfo callersFull routing, no DNS packet parsing
Stub on 127.0.0.53Programs reading resolv.confStandard DNS, caching, split DNS
Proxy on 127.0.0.54Tools needing raw upstream answersForwarding without local synthesis
Ways applications reach systemd-resolved

Per-link configuration is what makes systemd-resolved more than a cache: every network interface carries its own DNS servers and domains. NetworkManager, systemd-networkd or a VPN client pushes these values through D-Bus, and resolvectl status shows them per link.

Domains come in two kinds. A search domain is appended to single-label names and also routes queries, while a routing-only domain, written with a tilde such as ~corp.example, only steers matching queries to that link. The special entry ~. makes a link the default route for all queries, which is how full-tunnel VPNs prevent DNS leaks.

Link settingQuery for host.corp.exampleQuery for example.org
VPN with ~corp.exampleSent to VPN DNS serversSent to default links
VPN with ~.Sent to VPN DNS serversSent to VPN DNS servers
No domains on VPNSent to all default-route linksSent to all default-route links
VPN with DefaultRoute=noOnly if a domain matchesNever sent to VPN
Effect of domain settings on query routing

This split DNS model solves a long-standing problem: with a single resolv.conf, the last tool to write the file wins, and corporate names or private zones can silently resolve through the wrong servers.

Configuration and the resolv.conf modes

Global settings live in /etc/systemd/resolved.conf and drop-in files under resolved.conf.d, while per-link settings usually come from the network manager. Key options include DNS=, FallbackDNS=, Domains=, DNSSEC=, DNSOverTLS=, MulticastDNS=, LLMNR=, Cache= and DNSStubListener=.

How /etc/resolv.conf is handled determines whether legacy programs benefit from the service. systemd-resolved supports four integration modes, and the recommended one is a symbolic link to the stub file.

resolv.conf points toContentResult
/run/systemd/resolve/stub-resolv.confnameserver 127.0.0.53 plus search domainsRecommended, full split DNS
/run/systemd/resolve/resolv.confReal upstream serversBypasses cache and routing
/usr/lib/systemd/resolv.confStub address without search domainsStatic, minimal
A regular fileWhatever another tool writesService only reads it
Integration modes for /etc/resolv.conf

Changes are inspected and applied with resolvectl: resolvectl query host performs a lookup and shows the link used, resolvectl dns eth0 192.0.2.53 sets servers at runtime, resolvectl flush-caches clears the cache and resolvectl statistics reports cache hits and DNSSEC verdicts.

Security features: DNSSEC and DNS over TLS

systemd-resolved can validate DNSSEC signatures locally and can encrypt upstream traffic with DNS over TLS, but both features require care. The DNSSEC= option accepts yes, allow-downgrade or no, and the compiled-in default differs between distributions, so administrators should check it explicitly.

The allow-downgrade mode validates when the upstream server supports DNSSEC and falls back otherwise, which protects against misconfiguration but not against an active attacker who strips signatures. With DNSOverTLS=opportunistic the service tries TLS but accepts plaintext, while yes enforces encryption and fails closed if the server does not support it.

Common problems and how to diagnose them

Most systemd-resolved incidents stem from conflicting resolv.conf management or misunderstood routing domains. The table below lists typical symptoms with their usual cause and fix.

SymptomLikely causeFix
Internal names fail on VPNVPN link lacks a routing domainAdd ~corp.example to the link
DNS leaks outside the VPNOther links keep default routeSet ~. on the VPN link
Port 53 already in useStub listener blocks a local DNS serverSet DNSStubListener=no
Docker containers cannot resolve127.0.0.53 unreachable inside namespaceGive containers upstream servers
Stale answers after a changeCached records still validRun resolvectl flush-caches
Troubleshooting systemd-resolved

A frequent misconception is that cat /etc/resolv.conf shows the real DNS servers. On a system using the stub mode it only shows 127.0.0.53, and the actual upstream servers appear in resolvectl status.

The simple explanation

Every time a computer visits a website, it must turn a name into a numeric address. systemd-resolved is the built-in receptionist that handles those questions on many Linux systems. Programs ask it, and it asks the right outside servers, remembers the answers and replies quickly next time.

Its clever part is knowing whom to ask. Questions about the office network go to the office, and everything else goes to the usual internet provider, just as a receptionist routes calls to the right department.

How it is used in practice

A developer works from home on an Ubuntu laptop and connects to the company network through WireGuard. Internal services live under corp.example and are only known to the company DNS server at 10.20.0.53, while streaming and general browsing should stay on the home connection.

The VPN profile in NetworkManager sets the DNS server to 10.20.0.53 and the domain to ~corp.example, and leaves the home Wi-Fi link as the default DNS route. Running resolvectl query git.corp.example confirms the answer arrives through the wg0 link, while resolvectl query example.org uses the Wi-Fi link.

The result is reliable split DNS without editing resolv.conf: internal names resolve instantly, personal traffic never touches the corporate resolver and disconnecting the VPN removes its DNS settings automatically.