- Linux Administration Cookbook
- Adam K. Dean
- 409字
- 2021-07-02 14:24:33
Checking if NTP traffic is flowing
To confirm that NTP traffic is actually flowing, the catchall method is to check the port with tcpdump. NTP uses port 123, which is very easy to remember (there may be a quiz on this).
We know that default traffic should use eth0 for communication, so that's what we'll specify:
$ sudo tcpdump port 123 -i eth0
Soon, you should see your client trying to talk to upstream servers, asking for time information:
10:07:33.229507 IP centos1.37284 > ntp3.wirehive.net.ntp: NTPv4, Client, length 48
10:07:33.266188 IP ntp3.wirehive.net.ntp > centos1.37284: NTPv4, Server, length 48
10:07:39.411433 IP centos1.49376 > 5751b502.skybroadband.com.ntp: NTPv4, Client, length 48
10:07:39.453834 IP 5751b502.skybroadband.com.ntp > centos1.49376: NTPv4, Server, length 48
If you've not got tcpdump installed, you can also use chronyc.
Let's see what servers we're talking to by using the chronyc sources command:
$ chronyc sources
210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 85.199.214.100 1 6 377 18 +266us[ +309us] +/- 7548us
^- clocka.ntpjs.org 2 6 377 17 -126us[ -126us] +/- 37ms
^- linnaeus.inf.ed.ac.uk 3 6 377 17 -80us[ -80us] +/- 74ms
^+ 85.199.214.101 1 6 377 17 +166us[ +166us] +/- 7583us
We can get more granular information on the status of our client too by looking at the details it knows about from its last sync. In the following example, we can see that our time is very far off what's expected:
$ chronyc tracking
Reference ID : 5751B502 (5751b502.skybroadband.com)
Stratum : 3
Ref time (UTC) : Mon Aug 13 17:39:17 2018
System time : 26450.427734375 seconds slow of NTP time
Last offset : -0.000067056 seconds
RMS offset : 777.442565918 seconds
Frequency : 1.700 ppm slow
Residual freq : -0.120 ppm
Skew : 3.203 ppm
Root delay : 0.052811030 seconds
Root dispersion : 0.006966238 seconds
Update interval : 60.0 seconds
Leap status : Normal
Assuming that your time isn't ridiculously far out, the output may look as follows. Here, the amount of time difference between upstream and us is negligible:
$ chronyc tracking
Reference ID : 55C7D666 (85.199.214.102)
Stratum : 2
Ref time (UTC) : Sun Aug 19 10:55:55 2018
System time : 0.000031875 seconds slow of NTP time
Last offset : -0.000032510 seconds
RMS offset : 0.003755528 seconds
Frequency : 6.102 ppm slow
Residual freq : -0.009 ppm
Skew : 3.659 ppm
Root delay : 0.014116751 seconds
Root dispersion : 0.000280226 seconds
Update interval : 64.4 seconds
Leap status : Normal