Encrypted DNS Explained: DoH vs DoT and How to Set It Up on Every Device
Ordinary DNS is sent in plain text. Every time your phone or laptop looks up a domain, that question travels across your Wi-Fi, your ISP, and anything else along the path, and anyone in the middle can read it or even tamper with the answer. Encrypted DNS fixes that by wrapping the lookup in TLS, the same technology that protects websites.
This guide explains the main flavours of encrypted DNS, shows how to turn it on for each kind of device, walks through what it takes to run your own encrypted endpoint, and covers how to test it and what it still does not hide.
What encrypted DNS protects
Encrypted DNS protects the conversation between your device and the DNS server you chose. That gives you:
- Privacy on shared networks. On café, hotel, or airport Wi-Fi, other people on the network can no longer read your lookups.
- Protection from tampering. A hostile network can't silently rewrite answers to send you somewhere else, because the connection to your resolver is authenticated.
- A way around the default resolver. Your lookups go to the server you picked instead of whatever your ISP or carrier hands out.
It does not make you anonymous. Your ISP can still see the IP addresses you connect to, and often the site name sent during the TLS handshake. Encrypted DNS closes one door, not all of them.
DoT, DoH and DoQ: what's the difference?
All three do the same job. They differ in how they travel across the network.
- DoT (DNS over TLS) uses a dedicated port, 853. It is simple and efficient, and because it has its own port, network administrators can easily see that it is in use, or block it.
- DoH (DNS over HTTPS) sends DNS inside ordinary HTTPS on port 443. It looks like normal web traffic, which makes it harder to block, and it is what browsers tend to use.
- DoQ (DNS over QUIC) is the newest option. It runs over QUIC and is standardised, but client support is still limited compared with DoT and DoH.
For everyday use, the practical rule is simple: use whichever one your device supports natively. Android's system setting uses DoT. Browsers use DoH. Apple's configuration profiles can use either.
What you need before you start
Every device setting below asks for the same thing: a hostname (for DoT) or a URL (for DoH) that points at a resolver you trust. Large public resolvers publish theirs, so those are easy. If you want a private resolver with your own filtering and no shared logs, you need an endpoint of your own, and that is the part that takes work. The section "Running your own endpoint" covers it in detail.
Android
Android has encrypted DNS built into the system, so it applies to every app, on Wi-Fi and mobile data.
- Open Settings → Network & internet → Private DNS (the path varies slightly by manufacturer; searching Settings for "Private DNS" is quickest).
- Choose Private DNS provider hostname.
- Enter your resolver's hostname and save.
Android uses DoT for this setting. When you enter a hostname, Android requires an encrypted connection to it. If that server becomes unreachable, or its certificate expires, lookups fail rather than falling back to plain DNS. That is good for privacy, and worth knowing if something suddenly stops loading.
iPhone, iPad and Mac
Apple devices don't have a simple "enter a hostname" box. Instead, you install a DNS configuration profile that tells the system which encrypted resolver to use. The profile can specify DoH or DoT, and once installed it applies across the whole device.
- Get a
.mobileconfigprofile from your resolver provider, or create your own. - On iPhone or iPad, open the profile, then go to Settings → General → VPN & Device Management to install it.
- On a Mac, open the profile and approve it in System Settings → Privacy & Security → Profiles.
To remove it later, delete the profile from the same screen.
Windows 11
Windows 11 supports DoH in its network settings.
- Open Settings → Network & internet, pick your Wi-Fi or Ethernet connection, and open its hardware properties.
- Next to DNS server assignment, choose Edit and switch to Manual.
- Enter the resolver's IP address and set DNS over HTTPS to on, using the provider's DoH template URL if asked.
Windows has historically been fussy about custom DoH servers that aren't on its built-in list. If the interface won't accept yours, the netsh dns command can register a custom DoH template, and Microsoft's documentation covers the exact syntax for your build.
Linux
On systems that use systemd-resolved, DoT is a couple of lines in /etc/systemd/resolved.conf:
[Resolve]
DNS=203.0.113.10#dns.example.com
DNSOverTLS=yes
Replace the address and hostname with your resolver's, then restart the service:
sudo systemctl restart systemd-resolved
DNSOverTLS=yes is the strict mode, so lookups fail if the server can't be reached over TLS.
Browsers
Browsers can use DoH on their own, independently of the operating system. That is convenient for a single browser and confusing if you forget it is on.
- Firefox: Settings → Privacy & Security, scroll to DNS over HTTPS, and choose a provider or enter a custom URL.
- Chrome and Edge: Settings → Privacy and security → Security, turn on Use secure DNS, and choose a provider or a custom one.
One catch: a browser that uses its own DoH provider bypasses a network-level filter such as Pi-hole. If you run a filtering resolver, point the browser's DoH setting at it too, or turn browser DoH off and let the system handle DNS.
Running your own endpoint: what it actually involves
If you run a private resolver such as Pi-hole, it speaks plain DNS on port 53. To make it reachable over DoT or DoH, you put an encrypting front end in front of it. Here is the realistic shape of the job, so you can decide whether it suits you.
1. A hostname and a public address
Devices need a name to connect to and a certificate to match it, so you need a domain or subdomain you control, such as dns.yourdomain.com, pointing at your server.
- At home, your public IP address usually changes, so you also need dynamic DNS or a script that updates the record.
- Behind CGNAT, which many mobile and some fibre providers use, you have no public address at all, so inbound connections can't reach your Pi. The usual fix is to rent a small server elsewhere or set up a tunnel, which adds another moving part.
- You must open ports on your router (853 for DoT, 443 for DoH) and forward them to the right machine.
2. A TLS certificate that renews itself
Browsers and phones will reject a self-signed certificate, so you need one from a public certificate authority. A free automated one works well, using a tool such as certbot or acme.sh.
sudo certbot certonly --standalone -d dns.yourdomain.com
Certificates are short-lived by design, so renewal has to be automatic, and the service using the certificate must reload when it renews. Check that the renewal timer is actually running:
systemctl list-timers | grep certbot
3. A front end that terminates TLS
For DoT, a minimal nginx setup (it needs the stream module) looks like this:
stream {
server {
listen 853 ssl;
ssl_certificate /etc/letsencrypt/live/dns.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dns.yourdomain.com/privkey.pem;
proxy_pass 127.0.0.1:53;
}
}
For DoH, you need something that speaks HTTP/2 and understands DNS messages. dnsdist is a common choice, with a configuration along these lines:
addDOHLocal("0.0.0.0:443", "/etc/letsencrypt/live/dns.yourdomain.com/fullchain.pem",
"/etc/letsencrypt/live/dns.yourdomain.com/privkey.pem", "/dns-query")
newServer({address="127.0.0.1:53"})
Treat both as sketches. Option names change between versions, so check the documentation for what you have installed. Also expect practical snags: the proxy's user needs permission to read the certificate files, port 443 can clash with Pi-hole's own web interface if they share a machine, and Pi-hole must be set to accept queries from the proxy.
4. Don't build an open resolver
This is the step people skip, and the one that matters most. A DoT or DoH endpoint open to the whole internet is an open resolver, which strangers can use and attackers can abuse for DDoS amplification. You need to restrict who can use it: an allow-list of client addresses (hard when phones roam between networks), a secret URL path for DoH, or authentication features in your proxy. Whichever you choose, test it from outside your network to confirm it behaves as you intend.
5. Monitoring, so a silent expiry doesn't take your DNS down
With Android's strict Private DNS, an expired certificate means every lookup on the phone fails, and the symptom is "the internet is broken", not "the certificate expired". You can check expiry from any machine:
echo | openssl s_client -connect dns.yourdomain.com:853 2>/dev/null | openssl x509 -noout -dates
Many people put this in a scheduled check that emails them a warning.
How long does it take?
For someone comfortable with Linux, expect a few hours the first time, mostly spent on certificates, firewall rules, and testing. After that, the ongoing cost is small but real: renewals, proxy updates, and the occasional "why did DNS stop on my phone?" investigation. If you enjoy this kind of work, it is a rewarding project. If you would rather just have the endpoint, a managed option exists: NxValue Stack provisions a private Pi-hole + Unbound node with the DoH and DoT endpoints already generated, so the hostname is something you copy and paste rather than build. It works anywhere your phone has a connection, not only on your home network. You can try the demo node to see how the endpoint and dashboard look.
How to check that it's working
Don't assume a setting is doing what you think. A few quick checks:
-
Look at your resolver's logs. If you run a filtering resolver with a dashboard, load a few sites and confirm the queries from your device appear there. This is the most direct proof.
-
Use a DNS leak test. Sites such as dnsleaktest.com show which resolver is answering your lookups. You should see your chosen provider, not your ISP's.
-
Test the endpoint directly. For DoH,
curlcan send a query through it:curl --doh-url https://dns.yourdomain.com/dns-query https://example.com -IFor DoT,
kdig(from theknot-dnsutilspackage) can do the same:kdig +tls @dns.yourdomain.com example.com -
Test on mobile data and on another network. Settings that work at home sometimes behave differently on a carrier connection or a captive-portal Wi-Fi.
If a device still shows your ISP's resolver, something is overriding your setting, usually a browser, an app, or a router that redirects DNS.
Common problems
- Everything stops loading after enabling Private DNS. The hostname is probably mistyped, the server is unreachable, or the certificate has expired. Strict mode fails closed by design, so check these first.
- Hotel or airport Wi-Fi won't connect. Captive portals sometimes need plain DNS to show the login page. Temporarily switching Private DNS off, signing in, then switching it back on usually solves it.
- Blocking works on some devices but not others. A browser or app is probably using its own DoH. Check each browser's secure DNS setting.
- Works on Wi-Fi but not on mobile data. Some carriers restrict port 853. DoH on port 443 is less likely to be blocked, if your device supports it.
- Works at home but not away. Your endpoint may only be reachable from your home network, or your allow-list doesn't include the address your phone is using. Roaming devices make address-based restrictions awkward.
- Certificate errors. The hostname in the device setting must match the certificate exactly, and the server must send the full certificate chain.
Frequently asked questions
Does encrypted DNS slow things down? Slightly, on the first connection, because a TLS session has to be set up. After that the session is reused, and the difference is rarely noticeable. A nearby resolver with a good cache often feels faster than a distant one.
Does it work alongside a VPN? Usually the VPN takes over DNS and sends it through the tunnel, which overrides your device setting. If you want your own resolver while on a VPN, set it in the VPN's own configuration.
Do I still need DNSSEC? They solve different problems. Encrypted DNS protects the path between you and your resolver, while DNSSEC lets the resolver verify that answers really came from the domain's owner. They work well together.
Is encrypted DNS the same as a VPN? No. A VPN hides your traffic from the local network and your ISP by sending all of it through a tunnel. Encrypted DNS only protects DNS lookups.
Summary
- Encrypted DNS stops other people on the network from reading or altering your lookups. It doesn't hide the sites you connect to from your ISP.
- DoT uses port 853 and is what Android's system setting uses. DoH uses port 443 and is what browsers use. Apple devices can use either via a configuration profile.
- Every device needs a hostname or URL for a resolver. Public ones are easy to find, while private filtering resolvers need an encrypted endpoint of their own.
- Running your own endpoint means a domain, open ports, automatic certificates, a TLS front end, access control, and monitoring. It is very doable, and it is an ongoing responsibility.
- Always verify with resolver logs, a leak test, or a direct query, and remember that browsers can override system settings.
NxValue Stack is an independent service provider and is not affiliated with Pi-hole LLC. Pi-hole is a registered trademark of Pi-hole LLC. Android, Apple, Windows, Firefox and Chrome are trademarks of their respective owners.