DNS TCP or UDP: Ports, Fallback, and Troubleshooting

A DNS server connected to a router and devices by two different network paths.

DNS uses both: classic DNS sends most queries over UDP port 53, and it switches to TCP port 53 when a response is truncated, when an answer is too large for the UDP path, for zone transfers, and whenever a client or server chooses TCP. Both transports are part of the Domain Name System’s normal operation, so a network that only permits one of them will eventually break DNS resolution in ways that look random.

A DNS server connected to a router and devices by two different network paths.

The failures rarely announce themselves. A simple A record resolves fine, while a DNSSEC-signed domain, a long TXT record, or a zone transfer times out. If you want to troubleshoot DNS issues faster, knowing which transport each lookup uses tells you where to look first.

PacketTools approaches this from production experience: the same diagnostics used to verify VPNs and analyze routing apply directly to DNS transport problems. By the end, you will be able to read truncation flags, run safe dig comparisons, and write firewall rules that keep both transports working.

Why Do Most Classic DNS Queries Start With UDP?

Most DNS queries start with UDP because a lookup is one small question and one small answer, and UDP delivers that exchange with no connection setup. The trade-off is that UDP offers no delivery guarantee, so DNS clients handle loss themselves with timeouts and retries.

How Does a UDP Query Reach a DNS Server?

The User Datagram Protocol (UDP) is a connectionless transport layer protocol. DNS, an application layer protocol, rides on top of it. When your DNS client needs an IP address, it builds a query and sends it in a single datagram to UDP port 53 on its configured resolver.

During DNS resolution, Microsoft notes that DNS servers bind to UDP port 53, and queries leave from a high-numbered source port. The exchange runs like this:

  1. Your stub resolver checks its local cache.
  2. On a miss, it sends a UDP query to the recursive resolver.
  3. Recursive resolvers walk the delegation chain to the authoritative DNS server if they lack a cached answer (the process behind DNS recursion).
  4. The DNS response returns in one datagram to the client’s source port.

No handshake happens at any step. For common DNS record types such as A, AAAA, and MX, the whole lookup fits in a single packet each way.

What Are the Performance and Reliability Trade-Offs?

In the UDP vs TCP comparison, UDP wins on latency for small exchanges. TCP needs a three-way handshake before any data moves, which adds at least one round trip per new connection. Across billions of lookups, skipping that round trip is a large saving for resolvers.

Factor UDP TCP
Connection setup None Three-way handshake
Delivery guarantee No Yes, ordered
Header overhead 8 bytes 20+ bytes
Best DNS use Routine lookups Large answers, transfers

The cost shows up under packet loss. A dropped UDP packet produces silence, and the client waits for its timeout before retrying. On a lossy link, a single lookup can stall for seconds, which is why packet loss often surfaces first as “slow DNS” in user complaints.

When Does DNS Need TCP?

DNS needs TCP whenever an answer cannot travel safely in one UDP datagram, and for operations that demand reliable, ordered delivery. Truncated responses, DNSSEC-signed answers, large TXT sets, and zone transfers all lean on TCP port 53, and any client is free to use DNS over TCP for every query.

How Does the TC Flag Trigger TCP Fallback?

The Transmission Control Protocol (TCP) is a connection-oriented protocol, and DNS reaches it through a specific signal. When a response exceeds the size the client can accept over UDP, the server returns as much as fits and sets the TC (truncated) bit in the header.

A well-behaved client then reissues the same query over TCP port 53. Microsoft describes this as an approach that takes advantage of the performance of UDP but also has a backup failover solution for longer answers.

Over TCP, each DNS message is prefixed with a two-byte length field so the receiver knows where one message ends. If TCP port 53 is blocked, the client receives the truncated answer, attempts the retry, and fails. The user sees a timeout for that domain only.

How Does EDNS(0) Change the 512-Byte Limit?

Original DNS capped UDP messages at 512 bytes. Extension Mechanisms for DNS, known as EDNS or EDNS(0), let the client advertise a larger UDP packet size in an OPT pseudo-record. The server then scales its response to fit that buffer.

That means crossing 512 bytes does not automatically force TCP. A client advertising 1232 bytes receives a 900-byte answer over UDP without truncation. TCP enters only when the answer exceeds the advertised buffer.

Bigger buffers bring their own risk. Large UDP responses fragment at the IP layer, and fragments get dropped by firewalls and some IPv4 and IPv6 paths. DNS Flag Day 2020 pushed operators toward a default EDNS buffer of 1232 bytes to avoid fragmentation and let TCP carry anything larger.

Why Can DNSSEC Responses Need TCP?

DNSSEC adds RRSIG signatures to answers and DNSKEY records to key queries. A DNSKEY response for a zone mid key rollover can exceed 1,500 bytes, especially with RSA keys. Those responses hit the EDNS buffer ceiling and get truncated.

Validating resolvers therefore depend on TCP for a meaningful share of DNSSEC traffic. Cloud firewall guidance warns that DNSSEC and SPF might also require TCP connections, or some queries will not go through. Long SPF and verification TXT records hit the same limit.

How Do AXFR and IXFR Use Different Transport Rules?

Zone transfers copy zone data between authoritative servers. AXFR transfers the entire zone and always runs over TCP, because a partial zone is worse than none.

IXFR sends only the changes since a given serial number. The protocol permits an initial attempt over UDP, and if the difference is too large, the server truncates and the secondary retries over TCP. In practice, most implementations run IXFR over TCP from the start. Either way, secondaries need TCP port 53 open to their primaries.

Which Firewall Rules Keep DNS Working?

A network engineer views data flowing through a firewall between computers and a DNS server.

Permit both UDP and TCP port 53 to the DNS servers you approve, allow stateful return traffic to high source ports, and block port 53 everywhere else. Getting the return path and fragment handling right prevents the selective failures that make DNS outages hard to diagnose.

Allow Both UDP and TCP Port 53 to Approved DNS Servers

Write your egress policy around specific resolver IPs:

  • Clients to internal resolvers: allow UDP and TCP to port 53.
  • Internal resolvers to the internet: allow UDP and TCP to port 53 for recursion.
  • Inbound to authoritative servers: allow UDP and TCP from any address to port 53.
  • Secondaries to primaries: allow TCP 53 for AXFR and IXFR.
  • Everything else: deny port 53 to stop resolver bypass.

Cisco’s Umbrella guidance follows the same pattern: allow DNS (TCP/UDP) only to Umbrella DNS servers and block DNS to any other address. A rule that names only UDP silently breaks TCP fallback for every client behind it.

How Do Dynamic Source Ports and Stateful Return Traffic Work?

Queries leave from random high ports and return from port 53. Following IANA recommendations, Windows DNS uses dynamic ports from 49152 to 65535 by default; versions before Windows Server 2008 used 1025 through 5000.

A stateful firewall tracks the outbound flow and admits the reply automatically. Stateless ACLs need an explicit rule allowing source port 53 to destination ports 1024 to 65535 from the approved resolvers. Never pin resolvers to a fixed source port to simplify rules; source port randomization is a key defense against cache poisoning.

Why Do Blocked TCP and Dropped UDP Fragments Cause Selective Failures?

These two faults break only some names, so ordinary checks pass. Common patterns:

  • TCP 53 blocked: small lookups work; DNSSEC domains, long TXT records, and transfers time out.
  • UDP fragments dropped: answers above roughly 1,400 bytes vanish with no TC bit, so the client never knows to retry over TCP.
  • Middlebox inspection: “DNS-aware” firewalls that drop EDNS options or oversize packets.

When you see a DNS server not responding for specific domains while others resolve, test TCP before blaming the resolver. A DNS lookup failed error on one zone only is a strong hint of a transport problem.

How Can You Compare UDP and TCP With dig?

A network engineer examines two data paths connecting a computer to a DNS server.

Run the same DNS query over each transport against the same resolver, then shrink the EDNS buffer to watch truncation happen. These read-only queries are safe on any network you are authorized to test, and they isolate transport faults from record problems in minutes.

Compare UDP-Only and TCP Queries Against the Same Resolver

Pin the resolver so you compare like with like. The +notcp and +ignore flags stop dig from retrying silently, which keeps results honest:

dig @9.9.9.9 packettools.com A +notcp +ignore
dig @9.9.9.9 packettools.com A +tcp

Read the footer of each result. The ;; SERVER: line shows the resolver and port, and dig prints (TCP) or (UDP) there in recent versions. Compare query times too; the TCP query carries the handshake cost.

If UDP answers and TCP times out, something between you and the resolver blocks TCP 53. Repeat against the authoritative DNS server (dig @ns1.yourdomain NS +tcp) to see whether the fault sits on the recursive resolvers or on the authoritative side. Windows users can run similar checks with the nslookup command using set vc to force TCP.

Inspect Truncation and EDNS With Controlled Buffer Sizes

Force a small UDP packet size to provoke truncation on a large answer such as DNSKEY:

dig @1.1.1.1 cloudflare.com DNSKEY +dnssec +bufsize=512 +ignore
dig @1.1.1.1 cloudflare.com DNSKEY +dnssec +bufsize=1232
dig @1.1.1.1 cloudflare.com DNSKEY +noedns +ignore

In the header flags, look for tc. With +ignore, dig shows the truncated answer and stops; remove it and dig retries over TCP automatically, printing ;; Truncated, retrying in TCP mode.

The OPT PSEUDOSECTION line (EDNS: version: 0, flags: do; udp: 1232) shows the buffer the server returned. If the 1232 query hangs while the 512 query truncates cleanly and TCP retries succeed, suspect fragment drops on the UDP path.

Use PacketTools to Cross-Check Records and DNS Propagation

dig tells you what your vantage point sees. To confirm the records themselves, PacketTools’ DNS Lookup and the DNS propagation checker query from outside your network, with no IPs or queries logged.

If PacketTools returns the record correctly while your local dig over UDP fails, the record is fine and your network path is the problem. The SuperTool adds DNS, MX, SPF, DKIM, and DMARC checks in one pass, which helps when long SPF or DKIM TXT records are the answers getting truncated.

How Do Encrypted DNS Transports Differ From Port 53?

Encrypted DNS moves queries off port 53 entirely and wraps them in TLS or QUIC, so your port 53 rules neither allow nor block it. DoT uses TCP 853, DoH uses 443 over TCP or QUIC, and DoQ uses UDP 853.

Transport Protocol Port Encrypted
Classic DNS UDP, TCP 53 No
DNS over TLS (DoT) TCP 853 Yes
DNS over HTTPS (DoH) TCP or QUIC 443 Yes
DNS over QUIC (DoQ) UDP 853 Yes

DNS over TLS Uses TCP Port 853

DNS over TLS (DoT), defined in RFC 7858, opens a TCP connection to port 853 and negotiates TLS before sending standard DNS messages. Because the session persists, one handshake covers many queries, which offsets most of the connection cost.

A dedicated port makes DoT easy to identify. You can allow it to approved resolvers and block it elsewhere with a single rule, and Android’s Private DNS setting relies on it.

DNS over HTTPS Can Use TCP or QUIC on Port 443

DoH, defined in RFC 8484, carries DNS messages inside HTTPS requests. It runs over HTTP/2 on TCP 443 or HTTP/3 on QUIC over UDP 443. Windows Server 2025 gained server-side DoH with the 2026-06 Security Update (KB5094125), though upstream forwarding and zone transfers remain unencrypted.

Since DoH blends with web traffic, browsers using built-in DoH can bypass your internal resolver. Control that through browser policy and your DNS settings on managed devices.

DNS over QUIC Uses UDP Port 853

DoQ, defined in RFC 9250, runs QUIC on UDP port 853. QUIC streams avoid head-of-line blocking, so one lost packet stalls only its own query. Support is growing among resolvers such as AdGuard but remains narrower than DoT or DoH.

Why Encryption Does Not Replace Resolver Trust

Encryption hides queries from the network path. The resolver at the other end still sees every name you look up, so choosing that operator is a trust decision.

Encryption also leaves the data itself unauthenticated; DNSSEC handles that. Pair encrypted transport with validating resolvers, and run a DNS leak test to confirm queries reach the resolver you expect.

Keep Both Classic DNS Transports Available

Classic DNS depends on UDP for speed and TCP for completeness, and port 53 has to stay open for both. UDP carries routine lookups with no handshake. TCP takes over for truncated answers, oversized DNSSEC and TXT responses, AXFR and IXFR, and any client that prefers a stream.

Put that into practice with a short checklist:

  • Allow UDP and TCP 53 to approved resolvers and authoritative servers only.
  • Keep stateful return traffic open to high source ports.
  • Use an EDNS buffer near 1232 bytes to avoid fragmentation.
  • Test new firewall rules with dig +notcp +ignore and dig +tcp against the same server.
  • Treat DoT, DoH, and DoQ as separate policy items on ports 853 and 443.

When one domain fails while others resolve, run the TCP query first; that single comparison resolves most transport-related DNS resolution faults.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *