How DNS over TLS (DoT) Works: Encrypting DNS on Port 853

DNS over TLS (DoT) is a protocol standardized in RFC 7858 that encrypts DNS queries by wrapping them in a TLS connection on a dedicated port (853). Traditional DNS sends queries and responses as plaintext UDP datagrams on port 53, allowing anyone on the network path -- your ISP, a compromised router, a state surveillance system -- to observe, log, and even modify every domain name you look up. DoT eliminates this exposure by encrypting the transport layer between stub resolvers and recursive resolvers, providing confidentiality and integrity for DNS traffic without changing the DNS wire format itself.

The Problem: DNS as a Plaintext Protocol

DNS was designed in 1983 (RFC 882 and RFC 883, later consolidated into RFC 1034 and RFC 1035) with no consideration for privacy. Every DNS query contains the domain name being resolved, the query type, and the source IP of the requester. Every response contains the answer. Both travel in plaintext.

This creates several concrete problems:

DNSSEC provides authentication and integrity -- it proves that a DNS answer has not been tampered with -- but it does not encrypt queries. An observer still sees which domains you query. DoT and DNS over HTTPS (DoH) address the confidentiality gap.

How DNS over TLS Works

DoT is conceptually straightforward: take a standard DNS message (the same binary format defined in RFC 1035) and send it over a TLS-encrypted TCP connection to port 853 on the recursive resolver. The DNS message format does not change at all -- the encryption happens at the transport layer below it.

The process works as follows:

  1. TCP connection -- The client (stub resolver) opens a TCP connection to the recursive resolver on port 853.
  2. TLS handshake -- The client and server perform a standard TLS handshake. The server presents its certificate. Depending on the authentication mode (strict or opportunistic), the client may or may not validate this certificate.
  3. DNS query -- Once the TLS session is established, the client sends a DNS query prefixed with a two-byte length field (as specified in RFC 1035 Section 4.2.2 for TCP). The query itself is the same binary format as traditional DNS.
  4. DNS response -- The server responds with a standard DNS response, also length-prefixed, over the same TLS connection.
  5. Connection reuse -- The TLS connection remains open for subsequent queries, amortizing the handshake cost across multiple lookups.
DNS over TLS Connection Flow (Port 853) Stub Resolver DNS Resolver TCP SYN SYN-ACK ACK TLS 1.3 ClientHello + key_share ServerHello + key_share + Certificate + Finished Finished Encrypted Channel Established DNS Query: A example.com DNS Response: 93.184.216.34 DNS Query: AAAA example.com DNS Response: 2606:2800:220:1:... Connection reused -- no additional handshake

The TLS Handshake for DNS

The TLS handshake for DoT is identical to any other TLS handshake. With TLS 1.3 (which all modern DoT implementations support), this is a single round-trip:

  1. ClientHello -- The client sends supported cipher suites, a key share (for Diffie-Hellman key exchange), and the TLS version. In DoT, the SNI (Server Name Indication) field typically contains the resolver's hostname, such as dns.google or one.one.one.one.
  2. ServerHello -- The server selects a cipher suite, sends its key share, its certificate chain, and completes the handshake in a single flight.
  3. Finished -- The client verifies the server's certificate, completes its side of the key exchange, and sends the Finished message. From this point, all data is encrypted with the negotiated session keys.

With TLS 1.3, the handshake completes in one round-trip (1-RTT), and subsequent connections to the same resolver can use 0-RTT resumption to send data immediately. However, 0-RTT data is vulnerable to replay attacks, so DoT implementations must be careful about what they allow in early data.

Connection Reuse and Performance

The biggest performance concern with DoT is latency. A plaintext DNS query over UDP takes a single round-trip: send the query, receive the response. DoT requires establishing a TCP connection (1 RTT) and performing a TLS handshake (1 RTT with TLS 1.3, 2 RTT with TLS 1.2) before the first query can be sent. That is 2-3 round-trips before you get your first DNS answer, compared to one for traditional DNS.

RFC 7858 addresses this by strongly recommending connection reuse. Rather than opening a new TLS session for every query, the client keeps the connection open and sends multiple queries over the same session. This amortizes the handshake cost:

In practice, a persistent DoT connection to a resolver like 1.1.1.1 or 8.8.8.8 introduces negligible overhead for typical browsing, since most DNS queries after the initial burst use the existing connection. The stub resolver handles connection management transparently -- applications issue DNS queries the same way they always have.

RFC 7858 also permits pipelining: sending multiple DNS queries without waiting for responses. The two-byte length prefix on each message allows the receiver to frame messages on the TCP stream. This enables a burst of queries at the start of a page load (where a browser might resolve a dozen domains simultaneously) to complete in a single round-trip over an already-established connection.

Strict vs. Opportunistic Mode

DoT can operate in two authentication modes, and the distinction is critical for understanding its real-world security properties:

Strict Mode (RFC 8310)

In strict mode, the client validates the resolver's TLS certificate against a known identity. The client is pre-configured with the resolver's hostname (e.g., dns.google) or its SPKI (Subject Public Key Info) pin. If the certificate does not match, the connection is refused and the query fails -- the client does not fall back to plaintext DNS.

Strict mode provides genuine protection against man-in-the-middle attacks. An attacker who intercepts the connection to port 853 cannot present a valid certificate for dns.google (unless they have compromised the CA system or stolen Google's private key). The client will reject the connection entirely.

The downside: strict mode requires out-of-band configuration. The user or device must be pre-configured with the identity of a trusted DoT resolver. There is no way to "discover" that a resolver supports DoT and automatically verify it without some prior knowledge.

Opportunistic Mode

In opportunistic mode, the client attempts a TLS connection to port 853 but does not validate the server's certificate. If the connection succeeds, queries are encrypted. If port 853 is unreachable or the TLS handshake fails, the client falls back to plaintext DNS on port 53.

Opportunistic mode protects against passive surveillance (eavesdroppers who are recording traffic but not actively modifying it) but not against active attackers. An on-path attacker can either block port 853 (forcing fallback to plaintext) or present their own certificate (which the client will accept without validation). It is better than nothing, but it is not a security guarantee.

Most operating system DoT implementations default to opportunistic mode when the user simply enables "Private DNS" without specifying a resolver hostname. Android's Private DNS feature, for instance, operates in strict mode when a hostname is entered but opportunistic mode when set to "Automatic."

DNS Query Padding (RFC 7830)

Even with TLS encryption, DNS traffic leaks information through message sizes. DNS queries and responses have characteristic lengths -- a query for a.com is much shorter than one for very-long-subdomain.example.co.uk. An observer who cannot read the encrypted content can still perform traffic analysis, correlating message sizes and timing to infer which domains are being queried.

RFC 7830 defines a DNS padding option (EDNS0 option code 12) that allows clients and servers to pad DNS messages to a uniform size. RFC 8467 provides specific guidance on padding strategies for DoT:

The recommended approach from RFC 8467 is block-length padding with a block size of 128 bytes for queries and 468 bytes for responses. This provides a good balance between privacy and overhead.

DoT vs. DoH vs. DoQ: Encrypted DNS Compared

Three major protocols compete to encrypt DNS traffic. Each makes different architectural tradeoffs:

Encrypted DNS Protocol Comparison Property DoT (RFC 7858) DoH (RFC 8484) DoQ (RFC 9250) Port 853 (dedicated) 443 (shared w/ HTTPS) 853 (dedicated, UDP) Transport TCP + TLS TCP + TLS + HTTP/2 QUIC (UDP + TLS 1.3) Encryption TLS 1.2 / 1.3 TLS 1.2 / 1.3 TLS 1.3 only First Query 2-3 RTT 2-3 RTT 1 RTT (0-RTT resume) Blockability Easy (block port 853) Hard (same as HTTPS) Easy (block port 853) HoL Blocking Yes (TCP) Yes (TCP) No (independent streams) Primary Use OS-level resolvers Browsers, apps Next-gen resolvers RFC 7858 (2016) 8484 (2018) 9250 (2022)

DNS over TLS (DoT)

DoT uses a dedicated port (853), which makes it easy for network administrators to identify and manage. Enterprise networks can allow DoT to approved resolvers while blocking it to others. However, this same identifiability means that censors can trivially block all DoT traffic by blocking port 853. In countries like China, Iran, and Russia, port 853 is widely blocked.

DoT operates at the system level. When Android, iOS, Linux (via systemd-resolved), or Windows is configured to use DoT, all applications on the device benefit from encrypted DNS without any per-application configuration.

DNS over HTTPS (DoH)

DNS over HTTPS encapsulates DNS queries in HTTP/2 requests over port 443 -- the same port used for all HTTPS web traffic. This makes DoH nearly impossible to distinguish from regular web browsing, which is both its greatest strength (resistance to blocking) and its greatest controversy (network administrators lose visibility into DNS traffic on their networks).

DoH is primarily deployed in browsers (Firefox, Chrome, Edge, Safari) and operates at the application level. This means a browser can use a different DNS resolver than the system, which has led to significant debate about DNS centralization and the role of browser vendors in DNS policy.

DNS over QUIC (DoQ)

DoQ (RFC 9250) runs DNS over QUIC, which provides TLS 1.3 encryption natively with lower latency than TCP-based protocols. QUIC's independent stream multiplexing eliminates head-of-line blocking -- if one DNS response is delayed, it does not block other responses on the same connection. DoQ uses UDP port 853, matching DoT's port number but over UDP rather than TCP. It is the newest of the three protocols and is still in early deployment.

Privacy Implications and Resolver Trust

DoT encrypts the path between your device and the recursive resolver. This solves the surveillance problem at the network layer, but it does not eliminate all DNS privacy concerns:

The most privacy-conscious configuration combines DoT in strict mode with a trusted resolver that supports QNAME minimization, uses a resolver that commits to minimal or no logging, and uses Encrypted Client Hello for web connections. Even then, traffic analysis based on timing, volume, and destination IPs remains possible.

Deployment in Practice

DoT has seen broad deployment across operating systems and resolver services:

Client Support

Resolver Support

DoT and Network Policy

DoT's use of a dedicated port has important implications for network operators:

This creates a fundamental tension in the encrypted DNS debate. DoT gives network operators a clear signal to manage ("this is encrypted DNS traffic"), while DoH deliberately obscures that signal. Which approach is "better" depends entirely on whether you view network-level DNS visibility as a feature (for security monitoring and policy enforcement) or a bug (for user privacy and censorship resistance).

Security Considerations

Several security aspects are specific to DoT deployment:

DoT and the Broader Internet Architecture

DNS over TLS is part of a broader movement to encrypt all internet infrastructure protocols. DNS was one of the last major plaintext protocols, alongside protocols like the initial BGP session negotiation. The push to encrypt DNS reflects a recognition that metadata -- who you communicate with, when, and how often -- can be as sensitive as the content of the communication itself.

The routes that carry DoT traffic are themselves visible in the global BGP routing table. You can observe the network paths to major DoT resolvers, see which autonomous systems transit the traffic, and understand the physical topology that your encrypted queries traverse. The encryption protects the content; BGP determines the path.

Explore DNS Infrastructure with the Looking Glass

Use the god.ad BGP Looking Glass to trace the routes to major DoT resolver addresses and understand how encrypted DNS traffic traverses the internet. Look up Cloudflare's 1.1.1.1, Google's 8.8.8.8, or Quad9's 9.9.9.9 to see the BGP routes, origin ASNs, and network paths that carry your encrypted DNS queries. Examine the AS13335 (Cloudflare) or AS15169 (Google) to see how these resolver networks peer with the rest of the internet.

See BGP routing data in real time

Open Looking Glass
More Articles
How DNS Load Balancing Works: From Round-Robin to Global Server Load Balancing
How DNS over QUIC (DoQ) Works: Encrypted DNS Without Head-of-Line Blocking
What is BGP? The Internet's Routing Protocol Explained
What is an Autonomous System (AS)?
What is a BGP Looking Glass?
How to Look Up an IP Address's BGP Route