How to use systemd-resolved for DNS management
· Category: Linux
Short answer
systemd-resolved provides network name resolution caching and DNS configuration management.
Steps
- Check status:
resolvectl status
- Configure in
/etc/systemd/resolved.conf:
[Resolve]
DNS=8.8.8.8 1.1.1.1
FallbackDNS=8.8.4.4
DNSStubListener=yes
- Restart:
sudo systemctl restart systemd-resolved
- Query a hostname:
resolvectl query example.com
Tips
- Enable DNS over TLS for encrypted queries.
- Link
/etc/resolv.confto 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.confdirectly.