Cisco Router as an NTP Server and Client

Posted by
Facebooktwitterredditpinterestlinkedintumblr

[tweetmeme]I was asked if Cisco Router could both act as an NTP server and client. I answered “Absolutely yes. I couldn’t see any problem running both services in the same device”. Then a follow up question was added – “How can you do that?”. Well, you have to understand the concept of stratum. I don’t want to reinvent the wheel explaining in my own words what NTP is and its concepts. I found a great web link explaining all of this – Network Time Protocol.

Source: http://en.wikipedia.org/wiki/Network_Time_Protocol
NTP uses a hierarchical, semi-layered system of levels of clock sources. Each level of this hierarchy is termed a stratum and is assigned a layer number starting with 0 (zero) at the top. The stratum level defines its distance from the reference clock and exists to prevent cyclical dependencies in the hierarchy)

To illustrate this in Cisco device, let say you have three routers and these are R1, R2 (R1 & R2 are administered by you) and an external NTP server called R3 seating over the Internet.

Topology used in illustrating NTP Stratum concept.

R3 has a NTP stratum of 1. You’ve selected R1 as your internal NTP master in order to have a centralized time server for all your internal devices. That being said R1 must have an accurate time before we could make this an NTP master in your organization. Thus, R1 should be programmed to sync its time to R3.

In R1, enter this command.

R1(config)#clock timezone GMT+10
!Configure timezone.
R1(config)#clock summer-time GMT+10 recurring
!If your country observes Day Light Saving
R1(config)#ntp server 1.1.1.1
!Points to R3 IP address or to a real NTP server.

Once R1 is in sync with R3, determine what NTP stratum you get.

R1#show ntp status
Clock is synchronized, stratum 2, reference is 1.1.1.1
nominal freq is 250.0000 Hz, actual freq is 249.9996 Hz, precision is 2**18
reference time is D12728C9.FCF6449A (22:28:09.988 GMT+10 Sun Mar 13 2011)
clock offset is 1.8036 msec, root delay is 11.92 msec
root dispersion is 15.35 msec, peer dispersion is 13.52 msec

Now that we know the NTP stratum value we can proceed in setting up R1 as an NTP master. Execute the command presented below.

R1(config)#ntp master /stratum value from 1-15/

Question would be what value should I use? The answer is the stratum value must be higher than the value we determine previously. In this example, we know that we got Stratum 2 which follows that we must choose any value higher than 2.

In R2, we can now make R1 as its NTP server.

R2(config)#clock timezone GMT+10
!Configure timezone.
R2(config)#clock summer-time GMT+10 recurring
!If your country observes Day Light Saving
R2(config)#ntp server 192.168.2.1

Verification output from all three device – R1, R2 and R3 respectively.

R1#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 1.1.1.2 YES manual up up
FastEthernet1/0 192.168.2.1 YES manual up up
R1#sh run | s clock
clock timezone GMT+10 10
clock summer-time GMT+10 recurring
ntp clock-period 17179894
R1#sh ntp status
Clock is synchronized, stratum 2, reference is 1.1.1.1
nominal freq is 250.0000 Hz, actual freq is 249.9996 Hz, precision is 2**18
reference time is D1272F89.FF13C56D (22:56:57.996 GMT+10 Sun Mar 13 2011)
clock offset is 4.3761 msec, root delay is 9.57 msec
root dispersion is 11.92 msec, peer dispersion is 7.52 msec

R2#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.2.2 YES manual up up
FastEthernet1/0 unassigned YES unset administratively down down
R2#sh run | i clock
clock timezone GMT+10 10
clock summer-time GMT+10 recurring
ntp clock-period 17179831
R2#sh ntp status
Clock is synchronized, stratum 3, reference is 192.168.2.1
nominal freq is 250.0000 Hz, actual freq is 250.0005 Hz, precision is 2**18
reference time is D1272F4F.74D99527 (22:55:59.456 GMT+10 Sun Mar 13 2011)
clock offset is -27.4883 msec, root delay is 17.61 msec
root dispersion is 67.95 msec, peer dispersion is 29.16 msec

R3#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 1.1.1.1 YES manual up up
R3#sh run | i clock
clock timezone GMT 0
clock summer-time GMT recurring
External_NTP_Server#sh ntp status
Clock is synchronized, stratum 1, reference is .LOCL.
nominal freq is 250.0000 Hz, actual freq is 250.0000 Hz, precision is 2**18
reference time is D1272FA0.2D05C641 (12:57:20.175 GMT Sun Mar 13 2011)
clock offset is 0.0000 msec, root delay is 0.00 msec
root dispersion is 0.02 msec, peer dispersion is 0.02 msec

Leave a Reply

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

*