NTP
The Network Time Protocol keeps clocks in sync to within milliseconds. Logs, Kerberos and TLS certificates all depend on correct time, and exposed NTP servers have powered some of the largest DDoS attacks.
- OSI layer
- 7 Application
- Carried in
- UDP
- Ports
- 123/udp, 4460/tcp (NTS key exchange)
- Wireshark filter
ntp- Encrypted
- no
Packet structure
Select a field to see what it does.
Requests and replies use the same 48-byte format. Client requests are mostly zeros except mode, version and the transmit timestamp.
How it works
sequenceDiagram
participant C as Client
participant S as Server :123
Note over C: T1 = transmit time
C->>S: Mode 3 (client), Transmit = T1
Note over S: T2 = receive time, T3 = transmit time
S->>C: Mode 4 (server), Origin = T1, Receive = T2, Transmit = T3
Note over C: T4 = arrival time
The client computes:
- Offset (how wrong its clock is) = ((T2 − T1) + (T3 − T4)) / 2
- Round-trip delay = (T4 − T1) − (T3 − T2)
It polls several servers, throws out outliers and slowly adjusts its clock (slewing) instead of jumping. Servers form a hierarchy of strata: stratum 1 servers have a reference clock (GPS, radio, atomic), stratum 2 syncs from stratum 1, and so on.
In Active Directory, members sync from their domain controller, DCs from the PDC emulator, and the PDC from an external source. Windows uses the same packet format (W32Time).
In Wireshark
| Filter | Shows |
|---|---|
ntp | All NTP |
ntp.flags.mode == 3 | Client requests |
ntp.flags.mode == 4 | Server replies |
ntp.flags.mode == 7 | Private mode (monlist): should not exist |
ntp.flags.mode == 6 | Control queries (ntpq): reconnaissance from outside |
ntp.stratum == 0 | Kiss-o’-Death (rate limiting, access denied) |
ntp.flags.li == 3 | Unsynchronised servers |
udp.srcport == 123 && frame.len > 200 | Large NTP replies: possible amplification |
ntp && !(ip.dst == 10.0.0.0/8 || ip.dst == 172.16.0.0/12 || ip.dst == 192.168.0.0/16) | NTP leaving the network |
What normal looks like: clients talk to a few internal servers (or DCs) every 64 to 1024 seconds, 90-byte frames both ways. Large replies, mode 6/7 traffic from the internet, or many hosts querying random public NTP servers are worth a look. NTP to an unusual server with a regular beat can also be a covert channel, since few people check it.
Security notes
- Amplification DDoS: the
monlistcommand (mode 7) returned the last 600 clients, over 200 times the request size, to a spoofed source address. Disabled in ntpd 4.2.7 and later; block modes 6 and 7 from outside. - Time shifting: an on-path attacker or rogue server that moves a clock can expire or revive certificates, break Kerberos (5-minute skew limit), replay one-time codes, and scramble log timelines during an incident.
- No authentication by default: plain NTP trusts any answer that matches the request. NTS (Network Time Security) adds TLS-based key exchange and authenticated packets; symmetric keys work for internal setups.
- Kiss-o’-Death abuse: spoofed KoD packets can make a client stop querying its server.
- Reconnaissance: the Reference ID reveals upstream servers;
ntpq -c rvon an open server leaks version and OS. - Log integrity: incident response depends on synchronised clocks; make sure all hosts and appliances use the same internal source.
Versions and related
- NTPv3 (RFC 1305) is still found on old devices; NTPv4 (RFC 5905) is current.
- SNTP is a simplified client that queries one server without the filtering algorithms; most IoT devices use it.
- NTS (RFC 8915) secures NTP with a TLS key exchange on TCP 4460.
- PTP (IEEE 1588) gives sub-microsecond accuracy in data centres, finance and industrial networks.
- Runs over UDP. DHCP option 42 tells clients which NTP servers to use.
References
- RFC 5905: NTPv4
- RFC 8915: Network Time Security
- RFC 8633: NTP best current practices
- CVE-2013-5211: ntpd monlist amplification