How to Deploy systemd-resolved DNS over TLS (DoT) for Encrypted Local Name Resolution

In standard Linux server environments, DNS queries are transmitted in plaintext over UDP port 53. This architectural legacy presents a massive vulnerability. Any malicious actor positioned on the local network (or a compromised intermediary ISP router) can easily utilize packet sniffing tools (like Wireshark or tcpdump) to intercept, read, or even spoof these DNS requests. To prevent this telemetry leakage and guarantee the integrity of name resolution, Linux administrators must encrypt DNS traffic. The most robust, natively supported method on modern distributions (such as Ubuntu and Fedora) is configuring the systemd-resolved daemon to utilize DNS over TLS (DoT).

Understanding DNS over TLS (DoT)

Unlike DNS over HTTPS (DoH), which encapsulates DNS traffic within standard HTTPS web requests (port 443) to evade corporate firewalls, DNS over TLS (DoT) utilizes a dedicated port: TCP 853. DoT establishes a strict, cryptographically validated TLS tunnel between your Linux server and the upstream DNS resolver (e.g., Cloudflare 1.1.1.1, Google 8.8.8.8, or a private corporate Quad9 instance).

Because DoT utilizes TCP 853, it is highly visible to network administrators, allowing them to explicitly route or block encrypted DNS traffic at the firewall level. Crucially, the TLS handshake mathematically verifies the digital certificate of the upstream resolver, ensuring that a man-in-the-middle attacker cannot seamlessly intercept and spoof the connection (DNS hijacking).

Configuring systemd-resolved for DoT

On modern distributions, systemd-resolved acts as the local caching DNS stub resolver. It listens on the loopback interface (127.0.0.53) and forwards requests to the upstream servers defined by your DHCP lease or static configuration.

To enforce DoT, we must modify the global systemd-resolved configuration file.

Open the file utilizing your preferred text editor (requires root privileges):

sudo nano /etc/systemd/resolved.conf

By default, the [Resolve] section is entirely commented out. You must uncomment and modify the following specific directives to enforce strict TLS encryption.

[Resolve]
# Define the trusted upstream DoT resolvers (e.g., Cloudflare and Quad9)
DNS=1.1.1.1 9.9.9.9
# Define IPv6 fallbacks if necessary
FallbackDNS=1.0.0.1 149.112.112.112

# Enforce strict DNS over TLS
DNSOverTLS=yes

# (Optional but recommended) Enable DNSSEC validation
DNSSEC=yes

The DNSOverTLS Options

The DNSOverTLS directive accepts two operational states:

  • opportunistic: systemd-resolved will attempt to negotiate a TLS connection on port 853. If the upstream server does not support it, or if a firewall drops the packets, it will silently downgrade to plaintext UDP port 53. This provides no guaranteed security against active downgrade attacks.
  • yes (Strict Mode): systemd-resolved demands a mathematically validated TLS connection. If the connection fails, or the upstream server’s TLS certificate is invalid, the DNS query will categorically fail. This is the required setting for Zero Trust environments.

Applying and Verifying the Configuration

Save the configuration file and restart the daemon to apply the new cryptographic parameters:

sudo systemctl restart systemd-resolved

To mathematically confirm that the daemon is actively utilizing the DoT configuration, execute the resolvectl status command. The output will display the global parameters:

Global
       Protocols: -LLMNR -mDNS +DNSOverTLS DNSSEC=yes/supported
resolv.conf mode: stub

To definitively verify that traffic is actively flowing over the encrypted tunnel, you can utilize the tcpdump utility to monitor your physical network interface (e.g., eth0). Perform a DNS lookup (e.g., ping digitash.com) and simultaneously capture traffic on port 853:

sudo tcpdump -i eth0 -n port 853

You should observe bidirectional TCP traffic. If you attempt to capture traffic on port 53 (sudo tcpdump -i eth0 -n port 53), the output should be completely silent, proving that the Linux server has successfully isolated and encrypted all outgoing DNS telemetry.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.