Sub topic 16
Encrypted DNS: DoT and DoH
This chapter assumes you know how a stub resolver talks to a recursive resolver, how DNS messages travel over UDP and TCP, and what spoofing and eavesdropping threats look like. It also assumes you know what DNSSEC signs.
The gap that encryption fills
Classic DNS sends queries in plaintext on port 53. Anyone on the path between you and your recursive resolver can read which names you look up. They can also alter the replies.
DNSSEC does not close this gap. It signs the data so a validator can detect forgery, but the query and the answer are still visible. Encrypted DNS protects the link between the stub resolver and the recursive resolver. It gives you confidentiality and tamper detection on that one hop.
DNS over TLS (DoT)
DNS over TLS (DoT) wraps the ordinary DNS message format in a TLS session. It is defined in RFC 7858.
- It uses TCP port 853, a port reserved for this purpose.
- The DNS messages inside are the same as in plain DNS, with a two-byte length prefix as in DNS over TCP.
- The client checks the server's certificate, so it knows it is talking to the intended resolver.
Because DoT has its own port, a network operator can see that you use it. They can also block it by closing port 853.
DNS over HTTPS (DoH)
DNS over HTTPS (DoH) sends each DNS message as an HTTP request over TLS. It is defined in RFC 8484.
- It uses TCP port 443, the same port as ordinary web traffic.
- The request goes to a URL such as
https://dns.example/dns-query. - The body, or a base64url query parameter, carries the binary DNS message. The media type is
application/dns-message.
DoH traffic looks like other HTTPS traffic, so it is hard to single out and hard to block without also blocking websites.
Comparing the two
| Property | DoT | DoH |
|---|---|---|
| Port | TCP 853 | TCP 443 |
| Transport | TLS | HTTPS (HTTP over TLS) |
| Easy to identify and block | Yes | Harder |
| Typical place it runs | Operating system or router | Browser or application |
| Per-network policy control | Easier | Harder |
DoH is often configured inside a browser. The browser may then bypass the system resolver and its settings. That can surprise administrators who rely on local DNS for filtering or for internal names.
Trying it
Recent dig versions can query over TLS with +tls. Newer versions also support +https. This example uses DoT.
dig +tls @dns.google example.com A +noall +answerYou can also send a DoH request with curl. The accept header selects the JSON form that some public resolvers offer:
curl -s -H "accept: application/dns-json" \
"https://dns.google/resolve?name=example.com&type=A"What encrypted DNS does not do
- It does not hide the resolver from the network. The path to the resolver's IP address is still visible.
- It does not hide your destination. Your next connection to the server's IP address, and often the name in the TLS handshake, can still reveal the site.
- It does not protect the resolver's own upstream queries to authoritative servers. Those usually remain plain.
- It moves trust to the resolver you choose. That resolver sees every query you make.
- It does not replace DNSSEC. Encryption protects the hop. DNSSEC protects the data's authenticity along the whole chain.
Common errors
- Blocking port 853 and expecting DoT to fall back silently. Many clients use strict mode and fail, while others fall back to plaintext.
- Forgetting that the DoT or DoH server name needs a valid certificate. A mismatch causes the connection to fail.
- Forgetting that internal names, such as those in a private zone, will not resolve at a public encrypted resolver.
Exercise
A network administrator blocks outbound TCP port 853 but allows port 443. Which encrypted DNS protocol is still able to work, and why is it harder to stop?
Show answer
DoH still works. It uses TCP port 443 and looks like ordinary HTTPS traffic, so blocking it would also block normal websites. DoT depends on port 853, which the administrator closed.
Exercise
Does encrypted DNS replace DNSSEC? Explain in one or two sentences.
Show answer
No. DoT and DoH protect the link between the stub and the recursive resolver from eavesdropping and tampering. DNSSEC lets a validator verify that the data came from the zone owner, whichever path it took, so the two protect different things.