Network Time Protocol (NTP)
Synchronizing time across network devices is a critical service. While it might not seem important at first glance, many key network functions rely on accurate clocks, including:
- Time-based ACLs
- Expiring passwords and certificates
- Key exchange validation for VPNs and secure tunnels
- Accurate log timestamps for troubleshooting and correlation
NTP uses UDP port 123
NTP works on a hierarchical model called the Stratum model, which defines the “distance” a device is from the reference clock (usually an atomic or GPS clock).
- Stratum 0: Reference clock (atomic, GPS, etc.)
- Stratum 1: Directly connected to Stratum 0
- Stratum 2+: Syncs to a device at a lower stratum
Each hop away from the atomic clock increases the stratum level.
NTP Roles
Section titled “NTP Roles”Devices can participate in NTP in one of several roles:
NTP Client
Section titled “NTP Client”- Syncs time from a specified server
NTP Server
Section titled “NTP Server”- Provides time to other clients or peers
- Use
ntp masterif you’re making a router or switch act as an authoritative clock source
NTP Peer
Section titled “NTP Peer”- Two devices at the same stratum can peer
- Helps provide redundancy and resilience
- If both peers lose connection to their stratum-lower server, they can stay in sync with each other
NTP Peering is great for maintaining consistent time across a zone when the upstream clock source is temporarily unreachable.
NTP Configuration
Section titled “NTP Configuration”! Configure as a time source (typically on the "server" side)ntp master [stratum]
! Configure as an NTP clientntp server [ipaddress]
! Peer with another device (must be same stratum)ntp peer [ipaddress]
! Enable NTP authentication & Define authentication keyntp authenticatentp authentication-key [number] md5 [key-string]ntp trusted-key [number]ntp server [address] key [number]show ntp status ! View current sync status and stratumshow ntp associations ! View peers/servers and their reachabilityPrecision Time Protocol (PTP)
Section titled “Precision Time Protocol (PTP)”While NTP provides reasonable time synchronization (typically accurate within milliseconds), the Precision Time Protocol (PTP) is designed for applications that require much higher precision, often in the sub-microsecond range.
PTP is defined in IEEE 1588 and is commonly used in environments such as:
- Industrial automation
- Telecommunications (e.g., mobile backhaul, 5G)
- Financial trading systems
- Power distribution networks
| Feature | NTP | PTP |
|---|---|---|
| Accuracy | Milliseconds | Sub-microseconds |
| Transport Protocol | UDP (port 123) | UDP (port 319/320) or Ethernet |
| Hardware Support | Optional | Typically hardware-assisted |
| Use Case | General network devices | Precision-critical systems |