The idea: the same question in three envelopes

Before a browser can open https://shop.example, it asks a DNS resolver for the address. That question has to cross the café Wi-Fi and the ISP. Every router on the way forwards the packets, so every router can read what is not encrypted. The page sends the same lookup three ways: plain DNS on UDP port 53, DNS over TLS (DoT) on port 853, and DNS over HTTPS (DoH) on port 443. The notebook on the canvas shows what the on-path observer writes down each time.

Three rows, one per transport. Plain DNS on UDP 53: the observer reads the name shop.example and the answer 203.0.113.10. DNS over TLS on port 853: it sees only the resolver 192.0.2.53, port 853 and record sizes. DNS over HTTPS on port 443: it sees the resolver address, port 443 like any web site, and sizes. In all three the later HTTPS ClientHello shows the SNI shop.example.
DoT and DoH hide the name and the answer from the path, but the later HTTPS connection still shows the site in its SNI.

Plain DNS on port 53

The laptop's stub resolver sends a small UDP packet to the resolver the café's DHCP handed out, here the ISP resolver 198.51.100.53. The query for shop.example type A is 30 bytes: a 12-byte header with a 16-bit ID, the name, the type and the class. The answer is 46 bytes. Nothing is encrypted and nothing is signed, so the observer reads the name, the answer, the resolver and the times (Demo: plain DNS on UDP 53, then open the site).

DNS over TLS on port 853

DoT (RFC 7858) sends the same DNS message over a TLS connection on TCP port 853. Each message gets a 2-byte length in front, as in DNS over TCP. The first lookup costs a TCP handshake and a TLS 1.3 handshake; the laptop checks the resolver's certificate for dns.example. After that the connection stays open, and later lookups take one round trip. The observer sees a TLS connection to 192.0.2.53 port 853. The port alone says "this is DNS", so a network can block DoT easily (Demo: DNS over TLS on port 853).

DNS over HTTPS on port 443

DoH (RFC 8484) puts the DNS message in the body of an HTTPS request: POST /dns-query with content-type: application/dns-message, usually over HTTP/2. The answer comes back as status 200 with the same content type. On the wire it is just HTTPS to port 443, like the web pages next to it. The observer can only tell it is DNS if it knows the resolver's address or reads the SNI dns.example (Demo: DNS over HTTPS on port 443).

Nested boxes: the same 128-byte padded DNS message sits inside a 2-byte length and a TLS record for DoT (152 bytes), and inside HTTP/2 HEADERS and DATA frames for POST /dns-query and then a TLS record for DoH (about 208 bytes).
DoT and DoH carry the same DNS message; DoH adds an HTTP/2 POST around it, so it looks like web traffic.
laptop, café router, dns.example and shop.example, time going down. The laptop sends a ClientHello with SNI dns.example in clear text; dns.example answers with a ServerHello and an encrypted certificate; the laptop finds the certificate valid for dns.example. The laptop sends a 208-byte TLS record holding POST /dns-query for shop.example; the café router sees only 208 bytes to port 443 and not the name; dns.example logs shop.example and returns a 528-byte TLS record with 200 and A 203.0.113.10. Then the laptop's ClientHello to shop.example carries SNI shop.example in clear text, and the router reads it.
DoH hides the name from the café, but the resolver still reads it, and the next ClientHello's SNI still shows the site.
Plain DNSDoTDoH
PortUDP 53TCP 853TCP 443 (or QUIC)
Name and answerreadableencryptedencrypted
Looks likeDNSDNS (by its port)any HTTPS
Answer can be forged on the pathyesnono
First lookup1 round trip3 (TCP, TLS, query)3 (TCP, TLS, query)
Who sees the namesthe path and the resolverthe resolverthe resolver

Sizes, timing and padding

Encryption hides the bytes, not their number or their time. A 30-byte query for shop.example and a 32-byte query for clinic.example would give different record sizes. So DoT and DoH clients add an EDNS(0) padding option (RFC 7830): the recommended policy (RFC 8467) pads queries to a multiple of 128 bytes and answers to a multiple of 468. On the page both names give 152 / 492 bytes over DoT and about 208 / 528 over DoH (Demo: the resolver still sees every name). Timing still leaks: a DNS record followed at once by a connection to 203.0.113.10 tells the observer what was looked up.

Forged answers

Plain DNS trusts the first answer whose ID and port match the open query. An observer that can read the query has both, and it is closer to the laptop than the real resolver. Its forged answer A 203.0.113.66 arrives at 4 ms; the real answer at 24 ms finds no open query and is dropped (Demo: forged answer wins on plain DNS). HTTPS still saves the user here: the fake server cannot show a valid certificate for shop.example. Inside DoT or DoH a forged packet fails the TLS record check, because the router has no session key (Demo: forged answer fails against DoH). DNSSEC solves the same problem differently: it signs the records themselves, so even a lying resolver is caught, but it encrypts nothing.

What encryption does not hide

Two things stay visible. First, the next connection: the browser's TLS ClientHello carries the site name in the SNI field in clear text, and the server's IP address is in every packet. Only Encrypted Client Hello (ECH) hides the SNI, and only when the site supports it. Second, the resolver: it must read the question to answer it. DoT and DoH move your names from everyone on the path to the one resolver you chose. The canvas log shows dns.example getting every name.

Choosing a resolver

So the choice of resolver matters: read its privacy policy (what it logs and for how long), prefer one that validates DNSSEC, and use the strict profile (RFC 8310), where the client refuses to fall back to plain DNS when the certificate check fails. A browser that turns on DoH by itself may skip the resolver your company or school runs, and with it any filtering done there. That is a policy question, not a technical one.

See also How a DNS Name Is Resolved for what the resolver does after it gets the question, the HTTPS connection for the TLS handshake that DoT and DoH reuse, the TLS certificate chain for the certificate check, and VPN for hiding the whole path, SNI included, from the café.

What the page leaves out

The TCP handshakes (only counted in the times), recursion from the resolver to the root, TLD and authoritative servers, NAT details, DoH over HTTP/3 and DNS over QUIC (RFC 9250), GET requests with ?dns=, Oblivious DoH (RFC 9230), which hides the client's address from the resolver, the opportunistic DoT profile, Encrypted Client Hello, and how operating systems and browsers pick and fall back between resolvers. All sizes of HTTP/2 headers are toy values.

On the mind map

Open the Networking mind mapNetworkingLayers & links: frames on one local networkLayers & linksIP & routing: packets hop between networksIP & routingCore services: address, name and timeCore servicesTCP, UDP & sockets: end to end between two portsTCP, UDP & socketsHTTP & TLS: what a browser does per requestHTTP & TLSAPIs & push: how apps talk to serversAPIs & pushProxies & edge: boxes in the middle of the pathProxies & edgeContainers: virtual networks from Linux partsContainersReal-time media: voice and video over UDPReal-time mediaSecurity at the edge: filter traffic at the borderSecurity at the edgeDHCPDHCPDISCOVER, OFFER, REQUEST, ACK; renew at T1SNMP MIB and trapsSNMP MIB and trapsPoll to ask, trap to be told at onceNetFlow / IPFIXNetFlow / IPFIXFlow = key; export on FIN or timeoutDNS resolutionDNS resolutionroot, TLD, authoritative; cached for TTLDNS over HTTPS / TLSHides names from the path, not the resolverSMTP, IMAP and POP3SMTP, IMAP and POP3SMTP pushes to the MX; IMAP/POP3 pullDNSSEC chain of trustDNSSEC chain of trustparent's DS vouches for the child's KSKNTPNTP4 timestamps give clock offset and delayGPS TrilaterationGPS TrilaterationClock error is one more unknownOpen the Networking mind mapNetworkingaddress, name and timeCore servicesDHCPDHCPDISCOVER, OFFER, REQUEST, ACK; renew at T1SNMP MIB and trapsSNMP MIB and trapsPoll to ask, trap to be told at onceNetFlow / IPFIXNetFlow / IPFIXFlow = key; export on FIN or timeoutDNS resolutionDNS resolutionroot, TLD, authoritative; cached for TTLDNS over HTTPS / TLSHides names from the path, not the resolverSMTP, IMAP and POP3SMTP, IMAP and POP3SMTP pushes to the MX; IMAP/POP3 pullDNSSEC chain of trustDNSSEC chain of trustparent's DS vouches for the child's KSKNTPNTP4 timestamps give clock offset and delayGPS TrilaterationGPS TrilaterationClock error is one more unknown
This page on the Networking mind map · 83 pages in 10 branches · open it to see the whole map and test yourself in recall mode.