Use systemd-resolved to Enable DNS over TLS Support
Last updated on 2021-10-19, Tue, 12:37 AM
Intention
Use DNS over TLS to avoid potential censorship or poisoning.
Procedure
Let NetworkManager use systemd-resolved for name resolution.
sudo vim /etc/NetworkManager/NetworkManager.confAnd add such content:
[main]
dns=systemd-resolvedSave and exit, then set up DoT mode for systemd-resolved.
sudo vim /etc/systemd/resolved.confEdit the responsible part like this:
DNS=1.0.0.1 1.1.1.1 45.11.45.11
DNSOverTLS=yesI chose cloudflare and dns.sb here, and you can replace them with your own choice.
You can switch on DNSSEC validation if the server supports that.
Additionally, you may need to change the DNS server in /etc/resolv.conf.
sudo vim /etc/resolv.confToggle Comment all other nameservers and type:
nameservers 127.0.0.53Save. Then set up write protect for it.
sudo chattr +i /etc/resolv.confThen just enable systemd-resolved and restart NetworkManager.
sudo systemctl enable --now systemd-resolved
sudo systemctl restart NetworkManagerEverything should work as expected now.
P. S.
The lookup latency may be significantly longer than expected.
Then I made a terrible typo.
D N A