NTP

It is very simple to setup NTP. In summary here is the 3 steps.

1) Set the timezone

2) Set the time via CLI to get an immediate update

3) Sync up with an NTP source for persistent time sync.

Below is the steps fleshed out.

First we note the time before any changes

blogger@RIGHTY> show system uptime
Current time: 2012-01-28 12:59:45 UTC
System booted: 2012-01-28 11:04:00 UTC (01:55:45 ago)
Protocols started: 2012-01-28 11:07:47 UTC (01:51:58 ago)
Last configured: 2012-01-28 12:13:09 UTC (00:46:36 ago) by blogger
12:59PM  up 1:56, 1 user, load averages: 0.28, 0.13, 0.09


Then set the timezone. Note the change in the displayed time..

blogger@RIGHTY> edit
Entering configuration mode

[edit]
blogger@RIGHTY# set system time-zone Australia/Sydney

[edit]
blogger@RIGHTY# commit

commit complete

[edit]
blogger@RIGHTY# run show system uptime                  
Current time: 2012-01-29 00:00:47 EST

System booted: 2012-01-28 22:04:00 EST (01:56:47 ago)
Protocols started: 2012-01-28 22:07:47 EST (01:53:00 ago)
Last configured: 2012-01-29 00:00:34 EST (00:00:13 ago) by blogger
12:00AM  up 1:57, 1 user, load averages: 0.28, 0.15, 0.10

[edit]

Do an immediate sync of the time..

blogger@RIGHTY> set date ntp 192.168.10.1
28 Jan 15:59:03 ntpdate[2696]: step time server 192.168.10.1 offset -28949.425195 sec


Note the change in the displayed time again. Now showing correct local time.

blogger@RIGHTY> show system uptime          
Current time: 2012-01-28 15:59:09 EST

System booted: 2012-01-28 14:01:31 EST (01:57:38 ago)
Protocols started: 2012-01-28 14:05:17 EST (01:53:52 ago)
Last configured: 2012-01-29 00:00:34 EST (-8:-1:-25 ago) by blogger
 3:59PM  up 1:58, 1 user, load averages: 0.12, 0.13, 0.09

blogger@RIGHTY>

Now we set the time to sync permanently to an NTP server. Here is the config..

system {
    host-name RIGHTY;
    time-zone Australia/Sydney;
    ntp {
        server 192.168.10.1;
    }


Now check to see if the ntp is happening.

blogger@RIGHTY> show ntp associations
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 192.168.10.1    .STEP.          16 -  671   64    0    0.000    0.000 4000.00


Here is the show ntp associations command straight after the setting of the NTP server. Doesn't look good. Note the delay and offset show zeros, the stratum is 16 and the refid shows .STEP. - all signs that we are not yet actually synced to the ntp server.

A short while later..

blogger@LEFTY> show ntp associations   
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.10.1    203.0.178.191    3 -    9   64    1    2.119    2.565   1.164


This page shows the meaning of all the fields.
http://www.juniper.net/techpubs/en_US/junos/topics/reference/command-summary/show-ntp-associations.html

So we can see our peer is now selected for synchonisation and note the non zero values for delay and offset plus the stratum value. The refid is the remote ID of the server we are syncing to. I.e we get time from 192.168.10.1 and it (192.168.10.1) gets time from 203.0.178.191

The other command to check the status of NTP is..

blogger@LEFTY> show ntp status
status=06e4 leap_none, sync_ntp, 14 events, event_peer/strat_chg,
version="ntpd 4.2.0-a Thu Sep  8 06:31:49 UTC 2011 (1)",
processor="octeon", system="JUNOS10.4R7.5", leap=00, stratum=4,
precision=-17, rootdelay=168.239, rootdispersion=213.293, peer=59444,
refid=192.168.10.1,
reftime=d2ce1233.cdb543b2  Sat, Jan 28 2012 17:20:35.803, poll=6,
clock=d2ce13f2.d431f9e2  Sat, Jan 28 2012 17:28:02.828, state=4,
offset=-65.267, frequency=190.619, jitter=27.056, stability=97.949

No comments: