brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: turn on DNS over TLS in systemd-resolved

Systemd
~/tips/tip-dns-resolved-dot

[Resolve]

Makes systemd-resolved send all DNS queries over an encrypted TLS connection.

Your laptop sends DNS in plain text on every café Wi-Fi. systemd-resolved can encrypt it, and it is a config file away.

Create a drop-in instead of editing the main file:

# /etc/systemd/resolved.conf.d/90-dot.conf
[Resolve]
DNS=9.9.9.9#dns.quad9.net
DNSOverTLS=yes

Then restart with sudo systemctl restart systemd-resolved. The part after the # is the server name used for the certificate check. Without it, the certificate is checked against the IP address.

Mind the setting. yes means all queries are encrypted and, if the server cannot do TLS, they fail. opportunistic falls back to plain DNS, which the manual says is open to downgrade and man-in-the-middle attacks. For a laptop that moves between networks, strict is safer, but captive portals can then break until you log in. Quad9 here is just an example; pick a resolver you trust, and one that is covered by EU privacy law if that matters to you.

Check that it works with resolvectl status, which lists the DNS over TLS setting per link. Remember that a link can have its own DNS servers from DHCP too, and those may not support TLS. That is where strict mode breaks things most often.

Further reading: resolved.conf manual, On this site: resolvectl monitor streams every DNS query live, On this site: use-application-dns.net tells Firefox to leave DoH off, On this site: Guide: AdGuard Home with Unbound: resolve DNS yourself instead of asking Cloudflare or your ISP

More Systemd tips [Service] sudo mkdir -p /etc/systemd/system/service.d [Service] printf 'hunter2' | sudo systemd-creds encrypt --name=dbpass – dbpass.cred systemd-analyze timespan 1h30min All Systemd tips (88) All topics

Link