NTP

From Leo's Notes
Last edited on 30 March 2020, at 19:30.

The Network Time Protocol or NTP is a protocol to reliably obtain the current time from remote servers.

To query a NTP server, use the ntpdc command.

See Chrony for more information on the new NTP client/server used in Red Hat 8 / CentOS 8 or higher.

NTP Monlist[edit | edit source]

To see the peers of the local server, run:

$ ntpdc -c monlist

You can also try querying a remote server by running:

$ ntpdc -c monlist IP

NTP Peers[edit | edit source]

To see the peers of a server, run:

$ ntpq -pn

NTP Synchronization[edit | edit source]

To sync with a server, run:

$ ntpdate 136.159.5.75

You can get debug information with the -dv option:

$ ntpdate -dv 136.159.5.75

Systemd[edit | edit source]

You can also get systemd to handle time syncing using NTP. To enable, run:

## Edit the config at /etc/systemd/timesyncd.conf
# vi /etc/systemd/timesyncd.conf

## Enable
# timedatectl set-ntp true 

## Check status
# timedatectl status


If you get this error:

# timedatectl set-ntp true 
Failed to set ntp: Failed to activate service 'org.freedesktop.timedate1': timed out (service_start_timeout=25000ms)

It means you're missing the NTP package. Install NTP and try again.

Question: If systemd's just going to use the NTP service through this timedate abstraction, why wouldn't one just run ntp directly instead of dealing with systemd?

See Also:

Troubleshooting[edit | edit source]

When NTP stops syncing time, there are a few things to try:

  1. Does ntpdate -q timeserver produce any results? Possibly a network issue.
  2. Check the NTP server's peer list ntpq -pn to see if peers are bad.
  3. Use tcpdump port 123 to monitor NTP traffic.
  4. Verify that your ntp.conf is not restricting access or ignoring to your source servers. Try and use an unmodified configuration file and verify whether it works.

Server dropped: strata too high[edit | edit source]

136.159.5.75: Server dropped: strata too high
server 136.159.5.75, port 123
stratum 16, precision -22, leap 11, trust 000
refid [136.159.5.75], delay 0.02577, dispersion 0.00002
transmitted 4, in filter 4
reference time:    00000000.00000000  Sun, Dec 31 1899 16:26:08.000
originate timestamp: d7a8d436.b9474d41  Wed, Aug 27 2014 16:03:34.723
transmit timestamp:  d7a8d448.c3f0311e  Wed, Aug 27 2014 16:03:52.765
filter delay:  0.02588  0.02577  0.02582  0.02582 
         0.00000  0.00000  0.00000  0.00000 
filter offset: -18.0417 -18.0417 -18.0417 -18.0417
         0.000000 0.000000 0.000000 0.000000
delay 0.02577, dispersion 0.00002
offset -18.041794

The server is either misconfigured or there is a network issue between the client and the server. Verify that the client is not restricting the server.

Server dropped: Leap not in sync[edit | edit source]

136.159.2.251: Server dropped: Leap not in sync
server 136.159.2.251, port 123
stratum 1, precision -9, leap 11, trust 000
refid [NTP], delay 0.02748, dispersion 0.00070
transmitted 4, in filter 4
reference time:    d7a64b67.11374bc6  Mon, Aug 25 2014 17:55:19.067
originate timestamp: d7a8d4ab.fae147ae  Wed, Aug 27 2014 16:05:31.980
transmit timestamp:  d7a8d4ba.f4c9d0fb  Wed, Aug 27 2014 16:05:46.956
filter delay:  0.02831  0.02748  0.02757  0.03752 
         0.00000  0.00000  0.00000  0.00000 
filter offset: -15.0758 -15.0762 -15.0761 -15.0711
         0.000000 0.000000 0.000000 0.000000
delay 0.02748, dispersion 0.00070
offset -15.076202

The server may be misconfigured. Ensure that the server is synchronized or use another server.

On the server, force a sync by running ntpdate -b timeserver.