How to Check NTP Connectivity and Function on the Command Line

Any computer needs to have accurate and accurate date and time, and keeping time accurately without the use of NTP nowadays is troublesome given CPU tics cannot be relied upon in the virtualised world, and falling back to BIOS clocks is long considered bad practice given secure communication relies upon having time within a threshold of whom it wishes to communicate with.

With that said, Network Time Protocol configuration can be a pain the ass, especially considering it doesn’t tend to play well with basic Telnet connectivity checks either; this means you need a way to properly query the NTP server you’re targeting, and here’s how to do that on the Linux command line.

Querying an NTP Server on the Command Line

If all is well in your environment, after issuing the ntpdate command you should expect to wait a few seconds before being greeted with this response:

[email protected]:~$ ntpdate -q pool.ntp.org
server 109.74.206.120, stratum 2, offset -0.001523, delay 0.04782
server 139.59.199.215, stratum 2, offset -0.003559, delay 0.04453
server 185.53.93.157, stratum 2, offset -0.006328, delay 0.04576
server 193.150.34.2, stratum 2, offset -0.001938, delay 0.04889
3 Aug 16:31:11 ntpdate[24082]: adjust time server 139.59.199.215 offset -0.003559 sec

Here you can see the server’s queried in the pool specified and other particulars such as the delays, offset, etc…

If your machine cannot reach the NTP server, then you’ll see something like this:

[email protected]:~$ ntpdate -q pool.ntp.org
server 85.199.214.101, stratum 0, offset 0.000000, delay 0.00000
server 85.199.214.102, stratum 0, offset 0.000000, delay 0.00000
server 178.62.16.103, stratum 0, offset 0.000000, delay 0.00000
server 178.79.160.57, stratum 0, offset 0.000000, delay 0.00000
5 Jun 11:30:11 ntpdate[14437]: no server suitable for synchronization found

The key phrase to be looking for here is on the last line, stating no server could be found.

If you run into this, check your firewalls are allowing traffic from your host to your destination on port 123 over UDP.

Hope this helps, and please checkout some of my other posts for various how-to’s and ramblings.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.