NTP: the right time everywhere

Why time matters

Log messages from different devices only make sense side by side if every clock agrees. Certificates (HTTPS, VPNs) are only valid between two dates, and some logins use time-based codes. The Network Time Protocol (NTP, UDP 123) keeps clocks within milliseconds.

Strata

NTP is a hierarchy. An atomic or GPS clock is stratum 0; a server attached to it is stratum 1; its clients are stratum 2, and so on, up to 15. Stratum 16 means "not synchronised".

CommandDoes
ntp server 10.1.1.50Be a client of this server (add prefer for the favourite)
ntp master 3Trust our own clock and serve it at stratum 3 (for labs without a real source)
clock timezone CET 1Show local time (NTP itself always works in UTC)
show ntp associationsThe servers and their state (* = the one in use)
show ntp statusSynchronised or not, our stratum

Here R2 is an NTP master at stratum 3. Before R1 syncs, show clock starts with *: the time isn't trusted.

In NetLab

▶ R1
R1>enable
R1#show clock
*00:00:02.000 UTC Mon Mar 1 1993
R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#ntp server 10.0.12.2
R1(config)#clock timezone CET 1
R1(config)#end
*Mar  1 00:00:06.000: %SYS-5-CONFIG_I: Configured from console by console
R1#show ntp associations

  address         ref clock       st   when   poll reach  delay  offset   disp
*~10.0.12.2       127.127.1.1      3     12     64   377  1.000   0.250  0.190
 * sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured
R1#show ntp status | include Clock
Clock is synchronized, stratum 4, reference is 10.0.12.2      
R1#show clock
01:00:11.004 CET Mon Mar 1 1993

Tip: R1 is now stratum 4: one more than its server. It can serve the LAN itself, so the PCs and switches don't all have to reach R2.

HOME LABS COMMUNITY DASHBOARD