Testing an ntp server without ntpd

Using Nmap

If Nmap is available:

sudo nmap -sU -Pn -p 123 pool.ntp.org --script=ntp-info

Otherwise:

Using Netcat

Source: http://seriot.ch/ntp.php

GNU Linux

date -d@$((0x`printf c%47s|nc -uw1 pool.ntp.org 123|xxd -s40 -l4 -p`-64#23GDW0))

This doesn't work for autistic NTP servers like the one in Foritigate routers, because they dont understand that a space is the same as a NULL byte.. The longer, but more solid version:

date -d@$((0x`(printf "\x93"; printf '\0%.0s' {1..47}) |nc -uw1 192.168.9.1 123|xxd -s40 -l4 -p`-64#23GDW0))

For servers that don't accept ntpv2, but do ntpv4, try to replace x93 with xe3

BSD

date -r$((0x`printf c%47s|nc -uw1 pool.ntp.org 123|xxd -s40 -l4 -p`-64#23GDW0))

Howto/NTP (last edited 2021-09-23 13:23:35 by Burathar)