Skip to content

Network Time Protocol (NTP)

NTP🔗

Network Time Protocol
  • Time in seconds from 1900-01-01. Roll-over in 2036, but not a problem since it works with differences
  • accounts for round-trip time and processing time
Strata
Levels of accuracy where level 0 are certain atomic clocks. Stratum 16 is considered unsynched.
Synchronisation
Slewing: done in steps of 0.5ms or less
VMs
No reliable system clocks, but hypervisors can provide paravirtualised clocks to VMs. One can run a NTP serve on the host machine.
Linux
ntpd
  • supports all NTP4 modes (unlike `chronyd`)
  • broadcast
  • multicast
  • manycast
chronyd
  • better in intermittent networks
  • works in isolated networks
  • synchronises faster than ntpd
  • uses less memory than ntpd
Configure using NTP
timedatectl set-ntp true

chrony🔗

Configure server: in /etc/chrony.conf

  • activate NTP server functionality: allow NTP client access from local network
  • allow chronyc to control chronyd: add line cmdallow 192.168.1.0/24
  • peers: add to each other’s config
  • fall back to peers, then local, if remote isn’t available

Configure client: in /etc/chrony.conf add
server x.x.x.x iburst

Ensure using NTP
sudo timedatectl set-ntp true

Add exceptions to firewall, e.g.

1
2
3
4
sudo firewall-cmd --permanent --zone-public --add-service ntp
sudo firewall-cmd --reload # reload with new config
sudo firewall-cmd --list-all # check
sudo systemctl restart chronyd # restart NTP service

Check client status

1
2
chronyc sources -v # show NTP server info
chronyc tracking # show time sync info