NTP Configuration Example
NTP Configuration Example
NTP Configuration Example
This article will show you how to configure your Cisco router to synchronise its software clock from
external sources such as NTP servers. We will also show you how to configure your router to act as
an NTP server for your internal network devices, ensuring all devices are synchronised.
First example involves setting up the router to request NTP updates and synchronise itself from a
public NTP server. This will ensure the router's time is constantly synchronised, however it will not
act as an NTP server for internal hosts:
We'll need to configure the router to resolve FQDN using our ISP's name server:
Now we instruct our Cisco router to obtain its updates from the public NTP server.
As soon we issue the command, the router will resolve the FQDN into an ip address and begin its
synchronisation. Right after issuing the command, we can verify the router is correctly configured
and awaiting synchronisation:
The 'show ntp associations' command shows that the system is configured (~) to synchronise with
our selected NTP server, however, it is not yet synchronised. When it is, expect to see the star (*)
symbol in front of the tilde (~). The 'ref. clock' column shows the IP address of the NTP server from
which our public server (1.gr.pool.ntp.org) is synchronising.
It is also worth noting the column named 'st' which is equal to two (2). This represents the stratum
level. The higher the stratum, the closer to the Atomic clock source we are. As a general rule,
always try to synchronise with a server that has a low stratum.
The 'show ntp status' command confirms that we are yet to be synchronised with the NTP server
as it clearly states that the 'clock is unsynchronised' and also shows us the current system time: 1st
of Jan. 1900.
After a couple of minutes, we re-visit the CLI prompt and re-issue the commands with the following
results:
Looking at the new output, we can see that our Cisco router is now synchronising with the
configured peer (*) - public NTP server. Polling of the public NTP server will occur every 64
seconds, as shown in the command output.
The 'show ntp status' command also confirms the synchronisation, however, notice that the router
has set its stratum level to 3. This is expected as the reference is stratum 2. The time is now
correctly shown (01:17:15.562 Athens Sun Apr 19 2009).
The following two commands show the difference in time between the two clocks on our Cisco
router:
R1# show clock
01:51:31.532 Athens Sun Apr 19 2009
R1# show calendar
01:51:42 Athens Sun Apr 19 2009
While the difference is minor, we want to keep everything in our network synchronised as precisely
as possible.
Keep in mind that 'show clock' refers to the software clock and 'show calendar' refers to the
hardware clock of your router.
To synchronise the two clocks all we need to do is issue the following command:
R1# configure terminal
R1(config)# ntp update-calendar
The 'ntp update-calendar' forces the hardware clock to synchronise with the system's software
clock. After a couple of minutes, we check to see if the two clocks have synchronised:
R1# show clock
02:07:05.011 Athens Sun Apr 19 2009
R1# show calendar
02:07:05 Athens Sun Apr 19 2009
R1(config)# ntp master
The router now acts as an NTP server and is able to respond to internal clients NTP requests.
Checking the 'ntp association' will reveal that the router is obtaining its time synchronisation from
itself:
Thankfully Cisco provides a number of options that allow you to troubleshoot many aspects of your
NTP service.
R1# debug ntp ?
adjust NTP clock adjustments
all NTP all debugging on
core NTP core messages
events NTP events
packet NTP packet debugging
refclock NTP refclock messages
The most useful debug commands are the 'debug ntp events', 'debug ntp adjust' and 'debug ntp
core'. These three commands provide enough debugging to help you troubleshoot problems you
might encounter.
Closing, if you would like more information on the ntp associations created by your router you can
try the following command:
The 'show ntp associations detail' command will provide much information on the association
created with the NTP servers. This is most helpful when you see you are unable to create an
association with an NTP server.