Resolving DNS Quirks with systemd-resolved and Split DNSConfigs

Introduction to DNS Quirks and systemd-resolved

I’ve seen my fair share of DNS issues over the years, and in complex network environments, they can become a real headache. These problems often stem from misconfigured DNS servers, conflicting resolver settings, or the challenges of managing split DNS configurations. With systemd-resolved, managing DNS resolution has become more robust and secure. I’ve found it to be an essential tool in my Linux toolkit.

Understanding systemd-resolved

systemd-resolved is part of the systemd suite and provides a high-level interface for managing DNS resolution. It supports features like DNSSEC validation, LLMNR, and Multicast DNS. By using systemd-resolved, you can simplify your DNS configuration and benefit from its automatic management of resolv.conf, which helps prevent common issues like DNS leaks. To check if systemd-resolved is active on your system, you can use the following command:

systemctl status systemd-resolved

If it’s not running, you can enable and start it with:

sudo systemctl enable --now systemd-resolved

Don’t bother with manual resolv.conf edits when you have systemd-resolved handling it for you.

Managing Split DNS Configurations

In practice, split DNS configurations are necessary in environments where internal and external DNS queries need to be handled differently. For example, in a corporate network, internal hosts might be resolved through an internal DNS server, while external hosts are resolved through a public DNS service. systemd-resolved supports split DNS configurations through its Match and Domains directives in the /etc/systemd/resolved.conf file. Here’s an example of how you might configure systemd-resolved for a split DNS setup:

[Match]
Domains=example.com

[Resolve]
DNS=192.168.1.100
FallbackDNS=8.8.8.8

This way, any DNS query for the example.com domain will be sent to the DNS server at 192.168.1.100, and for all other domains, the fallback DNS server 8.8.8.8 will be used. The real trick is to ensure your internal DNS server is properly secured and only accessible from within your network.

Troubleshooting DNS Issues

When troubleshooting DNS issues with systemd-resolved, it’s helpful to understand how to query the resolver directly. The resolvectl command provides a powerful interface for this purpose. For instance, to query the IP address of a domain, you can use:

resolvectl query example.com

This command will show you the DNS servers used for the query, the response, and any errors encountered. I usually start with this command when debugging DNS issues.

Security Considerations

From a security perspective, using systemd-resolved with DNSSEC validation enabled can help protect against DNS spoofing attacks. DNSSEC ensures that DNS responses are authenticated, preventing an attacker from manipulating DNS records. To enable DNSSEC validation, you can add the following line to your /etc/systemd/resolved.conf file:

[Resolve]
DNSSEC=yes

It’s also important to keep your system and systemd-resolved up to date to ensure you have the latest security patches. This is where people usually get burned - neglecting to update their systems and leaving themselves open to known vulnerabilities.

Practical Tips and Trade-offs

  • When configuring split DNS, ensure that your internal DNS server is properly secured and only accessible from within your network.
  • Consider using a private DNS service for improved privacy and security.
  • Regularly review your DNS configuration to ensure it aligns with your network’s security policies. For more information on systemd-resolved and its capabilities, you can visit the systemd.io website, which provides comprehensive documentation on systemd and its components.

See also