Port 53 (DNS)
Key facts
- Port
- 53
- Protocols
- TCP, UDP
- Range
- System port (Well-Known), 0-1023
- IANA service name
- domain
IANA assigns ports in this range to well-known services, under RFC 6335.
About port 53
Port 53 is the port of DNS (Domain Name System), the service that translates domain names into IP addresses, and it runs over both UDP and TCP. Most DNS queries are sent over UDP, while TCP is used for large responses and for zone transfers between DNS servers.
The protocol is defined in RFC 1035, and IANA registers port 53 for the domain service.
What port 53 is used for
Two types of DNS servers listen on port 53, each with a different role:
- Authoritative server: holds the records of domains, such as A, MX, and TXT, and answers anyone who asks about them. These are the DNS servers set at the domain registrar.
- Recursive server (resolver): receives queries from computers and servers, finds the answer from the authoritative servers, and caches it for the time set in the TTL.
Even a server that doesn't provide DNS service sends outgoing DNS queries to port 53 whenever it needs to translate a domain name into an IP address.
Port 53 in the firewall
- Authoritative DNS server: open port 53 to incoming traffic from any address, on both UDP and TCP. Opening only UDP may cause large responses to fail, for example with DNSSEC records.
- Recursive server: allow access only to your own networks and servers, not to the whole internet.
- Server without DNS service: there's no need to open port 53 to incoming traffic. A firewall that tracks connections automatically allows the responses to outgoing queries.
For example, on an authoritative server: ufw allow 53 (opens TCP and UDP together) or firewall-cmd --permanent --add-service=dns.
Risks and security
A recursive server open to the whole internet (Open Resolver) can be abused for DNS amplification attacks: small queries with a spoofed source address are sent to it, and it sends large responses to the spoofed address. That's why you limit recursion to your own networks only.
- On an authoritative server, disable recursion completely.
- Allow zone transfers (AXFR) only to the addresses of your secondary DNS servers.
- Enable DNSSEC for the domain when the registrar and the DNS server support it, so responses can be verified.
- Enable Response Rate Limiting on the DNS server to reduce abuse.
Commands to check and configure
-
ss -tulpn | grep ':53 'Shows which processes are listening on port 53 on the server, on TCP and UDP.
-
dig @ns1.example.com example.com ASends a query directly to a specific DNS server and shows its response.
-
dig +tcp @ns1.example.com example.com ASends the same query over TCP, to make sure TCP is also open on port 53.
-
dig @ns1.example.com example.com AXFRChecks whether the server allows zone transfers. When the request comes from an address that isn't authorized, the response should be a refusal.
-
nslookup example.com ns1.example.comSends a query to a specific DNS server, also from a Windows computer.
-
ufw allow 53Opens port 53 on TCP and UDP (UFW).
-
firewall-cmd --permanent --add-service=dnsOpens port 53 on TCP and UDP in firewalld. Then run firewall-cmd --reload.
Port 53 in the IANA registry
| Port | Protocol | Service | IANA registry description |
|---|---|---|---|
| 53 | TCP | domain | Domain Name Server |
| 53 | UDP | domain | Domain Name Server |
Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)
Port 53 FAQ
Why does DNS use both UDP and TCP?
UDP is fast and lightweight, so most short queries and responses use it. When a response is too large, for example with DNSSEC records or long TXT records, the query is sent again over TCP. Zone transfers between DNS servers also use TCP, so an authoritative DNS server needs both protocols open.
Do I need to open port 53 on a web server?
No. As long as the server isn't used as a DNS server, there's no need to open port 53 to incoming traffic. The server sends outgoing DNS queries as usual, and the firewall allows the responses. Open port 53 to incoming traffic only on a server that provides DNS service for domains.
What is DNS over TLS, and which port does it use?
DNS over TLS is encrypted DNS between a computer and the recursive server, and it runs on port 853 over TCP. There's also DNS over HTTPS, where queries travel over port 443. Port 53 remains the port of regular DNS, and it's also used for communication between recursive servers and authoritative servers.
How do I check whether a DNS record change has propagated?
Send a query with dig or nslookup directly to the domain's authoritative DNS server, and compare it with the response from recursive servers. Recursive servers keep the previous answer until its TTL expires, so the update reaches them gradually. The dig commands page has examples of this check.