Network & delivery
8 min readUpdatedPort 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.
| Port | Transport | What runs there | Defined in |
|---|---|---|---|
| 53 | UDP | Classic DNS queries and answers | RFC 1035 (1987) |
| 53 | TCP | Large answers, zone transfers, retries after truncation | RFC 1035; mandatory since RFC 7766 (2016) |
| 853 | TCP | DNS over TLS (DoT) | RFC 7858 (2016) |
| 853 | UDP | DNS over QUIC (DoQ) | RFC 9250 (2022) |
| 443 | TCP, UDP | DNS over HTTPS (DoH), inside ordinary HTTPS | RFC 8484 (2018) |
| 5353 | UDP | Multicast DNS on the local network | RFC 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
# 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 A03DNS 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 role | Inbound 53, UDP and TCP | Recursion | Outbound |
|---|---|---|---|
| Authoritative only | Open to everyone | Off: refuse names outside your zones | Answers, plus zone transfers to your secondaries |
| Recursive resolver | Only from your own networks | On, for those networks only | Queries from random high ports to port 53 anywhere |
| Local stub on a host, such as 127.0.0.53 | Loopback only | Forwards to the configured resolver | To the upstream resolver |
| Both roles on one host | Split by address or view | Only for internal clients, never the world | As above |
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.
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: 106How 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.
| Symptom | Likely cause | Who produces the error | Test | Fix |
|---|---|---|---|---|
| Some names fail, often DNSSEC-signed or with many records | TCP 53 blocked, or large UDP answers fragmented and dropped | A firewall on the path; the client sees SERVFAIL or a timeout | dig +tcp name, then dig +bufsize=1232 name | Allow TCP 53; keep the EDNS buffer at 1,232 bytes |
| A DNS server will not start: address already in use | Another resolver already bound to port 53, often a local stub | The operating system, when the server binds | sudo 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 outside | A firewall or ACL drops external queries | The firewall, silently | dig @your-address from an outside host | Correct for a resolver; for an authoritative server, open UDP and TCP 53 |
| Outsiders get answers for any domain | Recursion allowed for everyone | Your own DNS server | The dig self-test above | Restrict recursion and the firewall to your networks |
| REFUSED for your own zone | Zone not loaded, or the query reached the wrong server | Your DNS server | dig @server yourzone SOA +norecurse | Check the zone and the NS records |
| Lookups fail on one network only | That network blocks or redirects port 53 or 853 | The local network | Compare dig results on another network | Use 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.
- 01RFC 1035: Domain Names, Implementation and Specification · IETF
- 02RFC 7766: DNS Transport over TCP, Implementation Requirements · IETF
- 03RFC 9210 (BCP 235): DNS Transport over TCP, Operational Requirements · IETF
- 04RFC 6891: Extension Mechanisms for DNS (EDNS(0)) · IETF
- 05RFC 7858: Specification for DNS over Transport Layer Security (TLS) · IETF
- 06RFC 9250: DNS over Dedicated QUIC Connections · IETF
- 07RFC 8484: DNS Queries over HTTPS (DoH) · IETF
- 08RFC 5358 (BCP 140): Preventing Use of Recursive Nameservers in Reflector Attacks · IETF
- 09RFC 5452: Measures for Making DNS More Resilient against Forged Answers · IETF
- 10DNS Flag Day 2020 · DNS Flag Day
- 11Alert TA14-017A: UDP-Based Amplification Attacks · CISA
- 12systemd-resolved.service(8) · freedesktop.org
Last updated