How to use systemd-resolved for DNS management

· Category: Linux

Short answer

systemd-resolved provides network name resolution caching and DNS configuration management.

Steps

  1. Check status:
resolvectl status
  1. Configure in /etc/systemd/resolved.conf:
[Resolve]
DNS=8.8.8.8 1.1.1.1
FallbackDNS=8.8.4.4
DNSStubListener=yes
  1. Restart:
sudo systemctl restart systemd-resolved
  1. Query a hostname:
resolvectl query example.com

Tips

  • Enable DNS over TLS for encrypted queries.
  • Link /etc/resolv.conf to the stub resolver:
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  • Supports mDNS and LLMNR for local name resolution.

Common issues

  • Stub listener conflicts with other local DNS servers.
  • Some applications bypass systemd-resolved and read /etc/resolv.conf directly.