Wednesday, December 17, 2014

ntpd - Tracing chain of NTP servers



For educational purposes I wanted to trace a chain of NTP servers, e.g. 0.de.pool.ntp.org back to a stratum 1 NTP server.
How can I do this?






I found ntptrace, but it doesn't work:



/home/xyzdragon# ntptrace

localhost: stratum 2, offset -0.009285, synch distance 0.010221
192.53.103.104: timed out, nothing received
***Request timed out


I tried to debug /usr/bin/ntptrace by reproducing the steps of that Perl-script manually:



home/xyzdragon# ntpq -n
ntpq> pe
remote refid st t when poll reach delay offset jitter

==============================================================================
+78.47.249.19 56.1.129.236 3 - 129 128 376 27.339 14.405 12.857
ntpq> host 78.47.249.19
current host set to 78.47.249.19
ntpq> pe
78.47.249.19: timed out, nothing received
***Request timed out


Actually ntptrace uses a combination of rv and pstat instead of the pe ntpq command.




After several tries getting it to work with ntpq, I just used a workaround:




  1. Read peer and refid from `ntpq -p

  2. Insert server 56.1.129.236 (skipping 78.47.249.19) into /etc/ntp.conf

  3. Apply settings with sudo service ntp restart

  4. Go to 1.




This works to trace an NTP chain, but it is very tedious. My questions therefore are:




  • How can I use maybe ntpq only to trace the NTP server chain?

  • Why isn't ntptrace working in the first place?


Answer



From the man page of ntptrace:





ntptrace is a perl script that uses the ntpq utility program to follow the chain of NTP servers from a given host back to the primary time source. For ntptrace to work properly, each of these servers must implement the NTP Control and Monitoring Protocol specified in RFC 1305 and enable NTP Mode 6 packets.



No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...