Port 123 (NTP)

Port 123 is the port of NTP (Network Time Protocol), the protocol servers and computers use to sync their clocks with accurate time servers, over UDP.

Key facts

Port
123
Protocols
UDP
Range
System port (Well-Known), 0-1023
IANA service name
ntp

IANA assigns ports in this range to well-known services, under RFC 6335.

About port 123

Port 123 is the port of NTP (Network Time Protocol), the protocol servers and computers use to sync their clocks with accurate time servers, over UDP. The same port serves both the server and the client: the computer's clock is kept up to date through small requests to the time server on port 123.

The current version of the protocol is defined in RFC 5905, and IANA registers port 123 for the ntp service.

What port 123 is used for

  • Syncing the server clock: a time service such as chrony or ntpd queries public time servers and keeps correcting the clock.
  • Time server for an internal network: one server syncs with external time servers, and the other computers and devices on the network sync with it.
  • Network equipment and systems: routers, cameras, phone systems, and time clock systems get the time from an NTP server.

An accurate clock matters for system logs you can compare, for checking SSL certificate validity, for two-factor authentication codes, and for scheduled tasks. The date and time formats page explains the different ways to write a date and time.

Port 123 in the firewall

A server that only syncs its own clock doesn't need port 123 open to incoming traffic. The connection goes out from the server to the time server, and a standard firewall allows the replies to requests that went out. You only need to make sure outgoing UDP traffic to port 123 isn't blocked.

A server that acts as a time server for an internal network opens the port to incoming traffic, only for the network's addresses:

  • UFW: ufw allow from 10.0.0.0/24 to any port 123 proto udp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="123" protocol="udp" accept'

Risks and security

An NTP server that answers any address on the internet can be abused for DDoS amplification attacks: small requests with a spoofed source address are sent to it, and it sends larger replies to the spoofed address. The common attacks abused old monitoring queries, such as monlist, that older servers used to answer.

  • Don't run a time server when the server only needs to sync its own clock. In chrony, the service answers clients only when the configuration file includes the allow directive.
  • When you do run a time server, allow access only from the internal network, both in the service settings and in the firewall.
  • In ntpd, block monitoring queries with the restrict directive and the noquery option.
  • Rate-limiting replies, for example with the ratelimit directive in chrony, cuts down traffic from clients that flood the server with requests.

Commands to check and configure

  • timedatectl

    Shows the time, the time zone, and whether clock sync is active.

  • chronyc tracking

    Shows the sync status in chrony: the current time source and the clock offset.

  • chronyc sources -v

    Shows the time servers the service queries and the status of each one.

  • chronyc makestep

    Corrects a large clock offset immediately, instead of adjusting it gradually (requires root).

  • ss -ulnp | grep ':123 '

    Checks whether any service is listening on UDP port 123, and on which address.

  • ufw allow from 10.0.0.0/24 to any port 123 proto udp

    Allows only the given internal network to sync its clock with the server (UFW).

  • firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/24" port port="123" protocol="udp" accept'

    Allows only the given internal network to sync its clock with the server in firewalld. Then run firewall-cmd --reload.

Port 123 in the IANA registry

Port Protocol Service IANA registry description
123 TCP ntp Network Time Protocol
123 UDP ntp Network Time Protocol

Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)

Port 123 FAQ

Do I need to open port 123 for the server clock to sync?

No. The server contacts the time servers itself, and the firewall allows the replies to requests it sent. You open port 123 to incoming traffic only when the server acts as a time server for other computers, and only for their addresses.

What's the difference between chrony and ntpd?

Both services sync the clock over NTP. chrony syncs quickly even when the server doesn't run continuously or the network is unstable, and it's the default service on many distributions, such as AlmaLinux and Rocky Linux. ntpd is the long-standing implementation of the protocol.

Why does the server clock need to be accurate?

An inaccurate clock causes errors that are hard to track down: SSL certificates look expired or not yet valid, two-factor authentication codes are rejected, and scheduled tasks run at the wrong time. On top of that, you can compare system logs from several servers only when their clocks are in sync.

How does NTP relate to the server's time zone?

The protocol syncs the clock to Coordinated Universal Time (UTC), and the time zone only sets how the time is displayed. So you change the time zone separately, for example with timedatectl set-timezone UTC, and syncing keeps working as usual.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement