Network & delivery

8 min readUpdated

Port 53: why DNS uses UDP and TCP, and when it moves to 853 or 443

Quick answer

Port 53 is the IANA-assigned port for DNS, over both UDP and TCP. Most queries use UDP, but TCP on port 53 is mandatory: RFC 7766 requires every DNS implementation to support it, for truncated answers, zone transfers and large DNSSEC responses. Encrypted DNS moves elsewhere: DNS over TLS uses TCP 853, DNS over QUIC UDP 853, and DNS over HTTPS port 443. An open recursive UDP 53 is an amplifier, so resolvers must be closed to outsiders.

01What is port 53 used for?

Port 53 is where DNS servers listen. IANA registers it as "domain" for both TCP and UDP, and RFC 1035, the 1987 DNS specification, already defined both: UDP for ordinary queries and TCP for longer messages. Two kinds of server answer on it: authoritative servers, which hold the records of their own zones, and recursive resolvers, which look up any name for their clients. Clients send queries from a random ephemeral port to port 53.

PortTransportWhat runs thereDefined in
53UDPClassic DNS queries and answersRFC 1035 (1987)
53TCPLarge answers, zone transfers, retries after truncationRFC 1035; mandatory since RFC 7766 (2016)
853TCPDNS over TLS (DoT)RFC 7858 (2016)
853UDPDNS over QUIC (DoQ)RFC 9250 (2022)
443TCP, UDPDNS over HTTPS (DoH), inside ordinary HTTPSRFC 8484 (2018)
5353UDPMulticast DNS on the local networkRFC 6762 (2013)

02Does DNS use TCP or UDP?

Both. UDP is the default because a lookup is usually one small question and one small answer, with no handshake needed. DNS moves to TCP in four cases:

  • The answer does not fit: the server sets the TC (truncated) flag and the client repeats the query over TCP. RFC 1035 limited UDP messages to 512 bytes; EDNS(0), RFC 6891, lets clients advertise a larger buffer
  • Zone transfers (AXFR and IXFR) between primary and secondary servers
  • Large DNSSEC-signed responses, which often exceed a safe UDP size
  • Clients that choose TCP or TLS, for example after repeated UDP loss or when using DNS over TLS on 853
Seeing when DNS falls back to TCP (filters compile with tcpdump -d)
# UDP answers with the TC bit set: the client will retry over TCP.
# udp[10] is the third byte of the DNS header; TC is its 0x02 bit.
# tcpdump marks such answers with a | after the query ID.
# IPv4 only: libpcap cannot index the UDP header inside IPv6 packets.
tcpdump -ni eth0 'udp src port 53 and udp[10] & 0x02 != 0'

# the TCP retries, plus any DNS over TLS
tcpdump -ni eth0 'tcp port 53 or tcp port 853'

# force a query over TCP to test the path
dig +tcp example.com A

03DNS over TLS, QUIC and HTTPS: ports 853 and 443

Classic DNS on port 53 is unencrypted, so anyone on the path can read and alter queries. Three standards encrypt it, and each leaves port 53.

DNS over TLS (RFC 7858) carries the same DNS messages inside TLS on TCP port 853. Because it has its own port, a network can see that DoT is in use, and block it, without being able to read the queries. DNS over QUIC (RFC 9250) uses UDP port 853. DNS over HTTPS (RFC 8484) sends queries as HTTPS requests, normally on port 443, where they look like other web traffic.

For operators that has two consequences. A resolver that offers DoT or DoQ must open port 853 to its clients, and a network that tries to control DNS by redirecting port 53 to its own resolver will not see DoH at all. Both are policy questions to settle with users, not problems a port rule can solve.

04Firewall rules for authoritative and recursive DNS servers

The right rule depends on the server's role. An authoritative server exists to answer the whole internet, but only for its own zones. A recursive resolver should answer only its own users. Mixing the two on one exposed address is how open resolvers happen.

Server roleInbound 53, UDP and TCPRecursionOutbound
Authoritative onlyOpen to everyoneOff: refuse names outside your zonesAnswers, plus zone transfers to your secondaries
Recursive resolverOnly from your own networksOn, for those networks onlyQueries from random high ports to port 53 anywhere
Local stub on a host, such as 127.0.0.53Loopback onlyForwards to the configured resolverTo the upstream resolver
Both roles on one hostSplit by address or viewOnly for internal clients, never the worldAs above
nftables input chain for a recursive resolver. For an authoritative server, replace the two DNS lines with: meta l4proto { udp, tcp } th dport 53 accept (passes nft -c, nftables 1.0.6)
define CLIENTS4 = { 10.0.0.0/8, 192.168.0.0/16 }
define CLIENTS6 = { fd00::/8 }
table inet filter {
    chain input {
        type filter hook input priority filter; policy drop;
        ct state established,related accept
        ct state invalid drop
        iif "lo" accept
        meta l4proto { icmp, ipv6-icmp } accept
        tcp dport 22 ip saddr 198.51.100.0/24 accept
        meta l4proto { udp, tcp } th dport { 53, 853 } ip saddr $CLIENTS4 accept
        meta l4proto { udp, tcp } th dport { 53, 853 } ip6 saddr $CLIENTS6 accept
    }
}

05Does your UDP 53 answer strangers? A one-line test

Run the test from a machine outside your network, such as a server elsewhere or a phone hotspot, because a resolver correctly set up for internal clients will still answer you from inside. Ask your server for a name it is not authoritative for, as in the command below, and compare its reply with the two real examples.

On the server itself, sudo ss -tulpn 'sport = :53' shows what is bound to the port. On systems with systemd-resolved, its stub listeners on 127.0.0.53 and 127.0.0.54 appear there; they are loopback-only by design and not a risk.

Self-test with dig. Replace 203.0.113.53 with your server's public address; the replies below are real, abridged
dig @203.0.113.53 example.com A +time=2 +tries=1

# closed: an authoritative-only server asked for a name outside its zones
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 45283
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
; EDE: 20 (Not Authoritative)

# open: a server that recursed for the asker (ra flag, answers returned)
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58319
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

06How port 53 is abused in DDoS attacks

Port 53 appears in two different attacks, and the direction of the port tells them apart. In DNS amplification, attackers send small queries with a forged source to resolvers that answer anyone, and the victim receives large answers from source port 53; CISA lists DNS amplification factors of 28 to 54, and the victim does not need to run DNS at all. In a DNS flood, bots send huge numbers of queries to destination port 53 of an authoritative server, often for random names that cannot be cached.

The first is harm your server does to others if it recurses for strangers, fixed by the rules above. The second is a capacity problem for your authoritative DNS, which is why large zones are served from anycast networks of name servers. Both sit alongside other reflection protocols in amplification attacks explained.

07What a reverse proxy or WAF can and cannot do for port 53

A web reverse proxy or WAF protects HTTP and HTTPS. It does not carry DNS on port 53, so it cannot shield your name servers, and if the domain's DNS goes down, visitors cannot find the protected site either. DNS needs its own resilience: name servers in more than one network, ideally on anycast with spare capacity.

What a proxy does change is what DNS reveals. With the site behind a proxy, the public A and AAAA records point at the proxy rather than the origin, one step in hiding the origin address. Old records, mail hosts on the same server and historical DNS data can still give the origin away. A DNS lookup shows what your public records return right now.

08Troubleshooting port 53: symptoms, causes and fixes

Start by finding out who produced the error: the client's resolver, a firewall on the path or the DNS server itself. dig shows the status code and which server answered, which usually settles it.

SymptomLikely causeWho produces the errorTestFix
Some names fail, often DNSSEC-signed or with many recordsTCP 53 blocked, or large UDP answers fragmented and droppedA firewall on the path; the client sees SERVFAIL or a timeoutdig +tcp name, then dig +bufsize=1232 nameAllow TCP 53; keep the EDNS buffer at 1,232 bytes
A DNS server will not start: address already in useAnother resolver already bound to port 53, often a local stubThe operating system, when the server bindssudo ss -tulpn 'sport = :53'Bind the server to specific addresses, or turn off the stub listener
Queries work inside the network but time out from outsideA firewall or ACL drops external queriesThe firewall, silentlydig @your-address from an outside hostCorrect for a resolver; for an authoritative server, open UDP and TCP 53
Outsiders get answers for any domainRecursion allowed for everyoneYour own DNS serverThe dig self-test aboveRestrict recursion and the firewall to your networks
REFUSED for your own zoneZone not loaded, or the query reached the wrong serverYour DNS serverdig @server yourzone SOA +norecurseCheck the zone and the NS records
Lookups fail on one network onlyThat network blocks or redirects port 53 or 853The local networkCompare dig results on another networkUse the resolver that network provides, or ask its administrator

Questions

Frequently asked questions

01Is port 53 TCP or UDP?
Both. DNS uses UDP port 53 for most queries because they are small and need no handshake, and TCP port 53 for answers too large for UDP, for zone transfers between servers and for retries after a truncated reply. RFC 7766 requires every DNS implementation to support TCP, so a firewall in front of a DNS server must allow both protocols on port 53.
02What is port 853 used for?
Port 853 is the IANA port for encrypted DNS. DNS over TLS, RFC 7858, uses TCP port 853, and DNS over QUIC, RFC 9250, uses UDP port 853. Clients that support them connect to a resolver on 853 instead of 53, so queries cannot be read or altered on the way. DNS over HTTPS is different: it uses ordinary HTTPS on port 443.
03Should port 53 be open on my server?
Only if the server is an authoritative name server for public zones, in which case UDP and TCP 53 must be open to everyone. A web or application server needs no inbound port 53: its own lookups go out to a resolver and the answers return on established flows. A recursive resolver should accept port 53 only from its own users and never from the whole internet.
04How can I tell if my DNS server is being used in attacks?
Look for large numbers of queries from addresses you do not serve, often for ANY or large records, and outbound traffic from port 53 far above normal. Then run the dig test from outside your network: a server that answers names outside its own zones for strangers can be used for amplification. Closing recursion to outsiders ends the abuse even if the queries keep arriving for a while.
05Why does DNS sometimes fail when TCP port 53 is blocked?
Because some answers do not fit in one UDP packet. The server then sends a truncated reply with the TC flag set, and the client must repeat the query over TCP port 53. If TCP is blocked, that retry fails and the lookup ends in a timeout or SERVFAIL. Large DNSSEC-signed answers are the usual victims, which is why the failures look random rather than total.

Sources

Sources and verification

Checked on 13 November 2026 on Debian 12: the capture filters in “Does DNS use TCP or UDP?” compile with tcpdump -d (tcpdump 4.99.3); the nftables ruleset in “Firewall rules for authoritative and recursive DNS servers” passes nft -c (nftables 1.0.6). Other configuration, commands, log lines and output on this page are examples: adapt them to your system and check them before use.

  1. 01RFC 1035: Domain Names, Implementation and Specification · IETF
  2. 02RFC 7766: DNS Transport over TCP, Implementation Requirements · IETF
  3. 03RFC 9210 (BCP 235): DNS Transport over TCP, Operational Requirements · IETF
  4. 04RFC 6891: Extension Mechanisms for DNS (EDNS(0)) · IETF
  5. 05RFC 7858: Specification for DNS over Transport Layer Security (TLS) · IETF
  6. 06RFC 9250: DNS over Dedicated QUIC Connections · IETF
  7. 07RFC 8484: DNS Queries over HTTPS (DoH) · IETF
  8. 08RFC 5358 (BCP 140): Preventing Use of Recursive Nameservers in Reflector Attacks · IETF
  9. 09RFC 5452: Measures for Making DNS More Resilient against Forged Answers · IETF
  10. 10DNS Flag Day 2020 · DNS Flag Day
  11. 11Alert TA14-017A: UDP-Based Amplification Attacks · CISA
  12. 12systemd-resolved.service(8) · freedesktop.org

Last updated