Port 53 is DNS. Authoritative name servers answer queries for their domains on it, and resolvers answer lookups for clients. Most queries use UDP; TCP is used for large responses and zone transfers. It should not be reachable from the public internet.
- Port
- 53
- Protocol
- UDP and TCP
- Service
- DNS
- Expose to internet?
- No
- Also used by
- BIND, Unbound, dnsmasq, PowerDNS, systemd-resolved, Pi-hole
Is port 53 safe to open?
An authoritative server for your domain must be public on port 53. A recursive resolver should not be: an open resolver answers anyone and is abused for DNS amplification attacks, where small spoofed queries generate large responses aimed at a victim. Unrestricted zone transfers can also leak every record in a zone.
How to secure DNS
- Disable recursion on authoritative servers, or limit it to your networks (BIND
allow-recursion, Unboundaccess-control). - Restrict zone transfers to secondary servers only (BIND
allow-transfer). - Enable response rate limiting if your server supports it.
- For a home or office resolver such as Pi-hole, allow port 53 only from the local network.
Check if port 53 is open
Linux: what is listening on this port
sudo ss -tulpn | grep ':53 'Windows (PowerShell): what is listening
Get-NetTCPConnection -LocalPort 53 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}From another machine: is it reachable
nc -zv HOST 53
# or
nmap -p 53 HOST
# Windows
Test-NetConnection HOST -Port 53Test the DNS service itself
dig @HOST example.com A +shortRestrict port 53 in the firewall
Replace 10.0.0.0/8 with the network or address that needs access. Docker publishes container ports through its own iptables rules, which bypass ufw; bind published ports to 127.0.0.1 (-p 127.0.0.1:53:53) instead of relying on the host firewall.
ufw: allow only your private network, deny everyone else
sudo ufw allow from 10.0.0.0/8 to any port 53 proto udp
sudo ufw deny 53/udpfirewalld: allow one source network only
sudo firewall-cmd --permanent --remove-port=53/udp
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="53" protocol="udp" accept'
sudo firewall-cmd --reloadiptables
sudo iptables -A INPUT -p udp --dport 53 -s 10.0.0.0/8 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 53 -j DROPWindows Firewall (PowerShell, as Administrator)
New-NetFirewallRule -DisplayName "Block 53 from internet" -Direction Inbound -Protocol UDP -LocalPort 53 -RemoteAddress Internet -Action BlockMonitor port 53
Run a TCP port monitor against your public IP on port 53: here, a failed connection is the healthy result, so you know the firewall is still doing its job. On Linux, the Statance agent also reports every listening port on the server. TCP port monitoring.
Related ports
FAQ
What is using port 53 on Ubuntu?
Usually systemd-resolved, which runs a local stub resolver on 127.0.0.53:53. It only listens on loopback. To run your own DNS server on port 53, set DNSStubListener=no in /etc/systemd/resolved.conf and restart systemd-resolved.
Does DNS use TCP or UDP?
Both. Ordinary queries use UDP. TCP is used when a response is too large for UDP and for zone transfers, so allow both on authoritative servers.
What is port 53 used for?
Port 53 is DNS. Authoritative name servers answer queries for their domains on it, and resolvers answer lookups for clients. Most queries use UDP; TCP is used for large responses and zone transfers. It is also used by BIND, Unbound, dnsmasq, PowerDNS, systemd-resolved, Pi-hole.
Is it safe to open port 53?
Not to the public internet. An authoritative server for your domain must be public on port 53. A recursive resolver should not be: an open resolver answers anyone and is abused for DNS amplification attacks, where small spoofed queries generate large responses aimed at a victim. Unrestricted zone transfers can also leak every record in a zone.
Is port 53 TCP or UDP?
DNS uses UDP and TCP on port 53.
How do I check if port 53 is open?
On the server, run sudo ss -tulpn | grep ':53 ' (Linux) or Get-NetTCPConnection -LocalPort 53 (Windows) to see what is listening. From another machine, run nc -zv HOST 53 or Test-NetConnection HOST -Port 53.
Know the moment a port stops answering.
TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.