UDP port 123 is the Network Time Protocol, used to keep system clocks in sync. Clients query time servers on it and time servers answer on it. It should not be reachable from the public internet.
- Port
- 123
- Protocol
- UDP
- Service
- NTP
- Expose to internet?
- No
- Also used by
- chrony, ntpd, systemd-timesyncd, Windows Time
Is port 123 safe to open?
Ordinary servers only need outbound NTP and do not have to accept inbound queries. Older ntpd versions answered the monlist command, which was widely abused for amplification attacks. A public time server is fine if it is configured to serve time only and refuse management queries.
How to secure NTP
- Use chrony, which does not serve time to other machines unless you add an
allowdirective. - On ntpd, restrict queries with
restrict default kod nomodify notrap nopeer noqueryand make suremonlistis disabled. - Block inbound UDP 123 on hosts that are only NTP clients.
Check if port 123 is open
Linux: what is listening on this port
sudo ss -ulpn | grep ':123 'Windows (PowerShell): what is listening
Get-NetUDPEndpoint -LocalPort 123From another machine: is it reachable
sudo nmap -sU -p 123 HOSTTest the NTP service itself
ntpdate -q HOSTRestrict port 123 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:123:123) 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 123 proto udp
sudo ufw deny 123/udpfirewalld: allow one source network only
sudo firewall-cmd --permanent --remove-port=123/udp
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="123" protocol="udp" accept'
sudo firewall-cmd --reloadiptables
sudo iptables -A INPUT -p udp --dport 123 -s 10.0.0.0/8 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 123 -j DROPWindows Firewall (PowerShell, as Administrator)
New-NetFirewallRule -DisplayName "Block 123 from internet" -Direction Inbound -Protocol UDP -LocalPort 123 -RemoteAddress Internet -Action BlockMonitor port 123
Run a TCP port monitor against your public IP on port 123: 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
Do I need to open port 123 on my firewall?
Only outbound, for the server to sync its clock. Inbound UDP 123 is only needed if the machine is itself a time server for other hosts.
What is port 123 used for?
UDP port 123 is the Network Time Protocol, used to keep system clocks in sync. Clients query time servers on it and time servers answer on it. It is also used by chrony, ntpd, systemd-timesyncd, Windows Time.
Is port 123 TCP or UDP?
NTP uses UDP on port 123.
How do I check if port 123 is open?
On the server, run sudo ss -tulpn | grep ':123 ' (Linux) or Get-NetTCPConnection -LocalPort 123 (Windows) to see what is listening. From another machine, run nc -zv HOST 123 or Test-NetConnection HOST -Port 123.
Know the moment a port stops answering.
TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.