Introduction to systemd-resolved
I’ve seen systemd-resolved cause some headaches in multi-network setups, so it’s worth understanding how it works. As part of the systemd suite, systemd-resolved is a DNS resolver that’s enabled by default on many modern Linux distributions, including Ubuntu and Fedora. The real trick is configuring it to avoid DNS surprises.
Configuring systemd-resolved
To get systemd-resolved working the way you want, you need to know how it uses DNS servers. It combines the DNS servers provided by your system’s network configuration with those specified in the /etc/systemd/resolved.conf file. Don’t bother with the network configuration; just modify the resolved.conf file to specify your preferred DNS servers. For example, to use Google’s public DNS servers, add the following lines to the [Resolve] section:
[Resolve]
DNS=8.8.8.8 8.8.4.4
After making changes, restart the systemd-resolved service to apply them:
sudo systemctl restart systemd-resolved
This is where people usually get burned - forgetting to restart the service.
Troubleshooting DNS Issues
If you encounter DNS resolution issues, the resolvectl command is your friend. It allows you to query the DNS resolver and view the current DNS server configuration. I usually start with the following command to view the current DNS server configuration:
resolvectl status
This command displays the current DNS server configuration, including the DNS servers used by the resolver. In practice, this is often the first step in troubleshooting DNS issues.
Security Considerations
From a security perspective, it’s crucial to ensure your DNS resolver uses secure DNS servers. You can use DNS over TLS (DoT) or DNS over HTTPS (DoH) to encrypt your DNS traffic. To enable DoT or DoH, add the following lines to the [Resolve] section of the /etc/systemd/resolved.conf file:
[Resolve]
DNSOverTLS=yes
DNSSEC=yes
For more information on configuring systemd-resolved, check out the systemd-resolved documentation on the freedesktop.org website.
Additional Resources
If you’re interested in learning more about DNS security, visit the DNS Privacy Project website, which provides valuable information on DNS privacy and security.
See also
- Taming Log Noise with jq and systemd Journal Filters
- Using resolvectl to Diagnose and Resolve Stubborn DNS Issues on Linux
- Using Find and Xargs to Safely Remove Unused Packages on a Crowded Linux System
- Debugging Local Network Issues with resolvectl and ss
- Troubleshooting SSH Connection Issues with Unknown Hosts and Missing Host Keys