Basic NTP Client Test: ntpdate & sntp

During my work with a couple of NTP servers, I had many situations in which I just wanted to know whether an NTP server is up and running or not. For this purpose, I used two small Linux tools that fulfil almost the same: single CLI command while not actually updating any clock but only displaying the result. That is: ntpdate & sntp. Of course, the usage of IPv6 is mandatory as well as the possibility to test NTP authentication.

This article is one of many blogposts within this NTP series. Please have a look!

Refer to my “Packet Capture: Network Time Protocol (NTP)” blog post in order to download a pcap with different NTP packets, or at least heaving a view of them at the screenshots.

ntpdate

You can use ntpdate with the “-q” switch to “Query only – don’t set the clock”. This is a very basic run:

When using an FQDN with a couple of A/AAAA records, ntpdate queries all of them:

Furthermore, you can query several names at once:

Debugging & NTP Authentication

Even more relevant for my lab tests is the ability to test NTP authentication. Therefore I am using the debugging mode “-d” which will print out all steps (while still not updating the local clock) in conjunction with -a <key-id> and -k <keyfile>. For this example I used two SHA1 keys from one of my NTP servers (ntp3.weberlab.de):

While key number 11 is indeed correct (receive: authentication passed):

I falsified key number 12 on purpose to test the output (receive: authentication failed):

Mission accomplished.

sntp

Just as an alternative you can use sntp as well. Sntp by default writes “the estimated correct local date and time (i.e. not UTC) to the standard output”:

The “kod_init_kod_db” warning is normal and can be ignored.

Debugging & NTP Authentication

Fortunately, the options are quite the same when it comes to debugging and NTP authentication. That is: -d -a <key-id> -k <keyfile>. Having the same two keys (11 ok, 12 not ok) in place, gives the following output for “authenticated using key id 11“:

as well as for “Crypto NAK“:

Please note that to my mind there was a bug at least in sntp version 4.2.8p10, since I got this “Segmentation fault” output from another machine (while the above-listed outputs were from version 4.2.8p12):

That’s it. ;) Happy troubleshooting.

Featured image “Reading glasses over a book” by Marco Verch is licensed under CC BY 2.0.

2 thoughts on “Basic NTP Client Test: ntpdate & sntp

Leave a Reply

Your email address will not be published. Required fields are marked *