NTP is another pretty common protocol seen on Cisco devices. NTP allows Cisco devices to use some central time source to set their local clock. Having the same time across all of your networking equipment is incredibly important when trying to correlate log messages on different devices.
In most production environments, there’s some kind of NTP server that all the networking devices use. If you don’t have one, you can always use one of the Cisco devices as the NTP source, and have the other sync off of that source. Let’s start with 3 routers, on the same Ethernet segment, that all have different times in their clocks…
router1#show clock
*00:52:13.235 UTC Sat Jan 12 2013
router2#show clock
*00:58:14.287 UTC Sat Jan 12 2013
router3#show clock
*00:53:45.875 UTC Sat Jan 12 2013
Let’s start by correctly setting the time out router1. The first thing to do is to configure the time zone and day light savings time…
router1(config)#clock timezone CST -6
router1(config)#clock summer-time CDT recurring
I’m in the central time zone so I configure the time zone as –6. I’ll lso configure daylight savings time on a recurring basis. Next, we need to set the actual time…
router1#clock set 18:56:00 11 JAN 2013
router1#show clock
18:56:10.287 CST Fri Jan 11 2013
Note that the process of setting the time isn’t actually done in config mode. Right, now that we have the proper time, we can work on configuring NTP. To configure router1 as the NTP server, all we have to do is configure the ‘ntp master’ command’ on router1…
router1#config t
Enter configuration commands, one per line. End with CNTL/Z.
router1(config)#ntp master
router1(config)#end
Now, if we go on router2, we need to first configure the time zone and DST (daylight savings time) as we did on router1…
router2(config)#clock timezone CST -6
router2(config)#clock summer-time CDT recurring
Then we just configure router1 as the NTP server…
router2(config)# ntp server 192.168.0.1
Now if we look at the clock we should see the right time…
router2#show clock
19:05:29.147 CST Fri Jan 11 2013
Furthermore, we can look at the NTP status…
From this output, we can see that the clock is in sync with router1. For router3, let’s use a different method to synchronize the clock. Back on router1, let’s go under the local interface and configure this…
router1#show run int fa0/1
Building configuration…
Current configuration : 151 bytes
!
interface FastEthernet0/1
ip address 192.168.0.1 255.255.255.0
ip flow ingress
ip nat inside
ip virtual-reassembly
duplex auto
speed auto
end
router1#config t
Enter configuration commands, one per line. End with CNTL/Z.
router1(config)#int fa0/1
router1(config-if)#ntp broadcast
router1(config-if)#end
router1#
Then, on router3, let’s configure the ‘ntp broadcast client’ command on it’s local interface…
router3#show run int fa0/0
Building configuration…
Current configuration : 97 bytes
!
interface FastEthernet0/0
ip address 192.168.0.47 255.255.255.0
duplex auto
speed auto
end
router3#config t
Enter configuration commands, one per line. End with CNTL/Z.
router3(config)#int fa0/0
router3(config-if)#ntp broadcast client
router3(config-if)#end
router3#
Now if we look at the NTP status and the clock, we can see that router3 is now also in sync…
So there you have it, a couple of different ways to configure NTP!