Commands / Services and tunnels

Services and tunnels

busybox ntpd

Also ntpd, sntp, ntpdate, time query

BusyBox's small NTP client and server; with -w it only asks a server and prints the offset, setting nothing.

busybox ntpd -w -d -p SERVER sends NTP requests to one server and prints each reply: the offset (how far this clock is from the server's, in seconds), the round-trip delay, the server's stratum and reference. It is an SNTP-style probe: one server, no voting. Without -w it would set the clock, which no lab device does: the containers share one kernel clock with the host.

busybox ntpd command usage

busybox ntpd -w -d [-q] -p SERVER

Options

-w
only query the servers, never set the clock
-d
print each exchange (on stderr)
-p SERVER
the server to ask; repeat for more
-q
quit after the first good answer

busybox ntpd examples

timeout 3 busybox ntpd -w -d -p timeServer.lab 2>&1 | grep reply
Asks timeServer for the time for three seconds and prints its answers.
tcpdump -nn -v -i eth0 udp port 123
Shows NTP requests and answers with their four timestamps.

Pitfalls

  • It runs until stopped: wrap it in timeout.
  • A negative offset means this clock is ahead of the server's.

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start free