How to configure the time on a Cisco router

Recently, I showed you how to configure the logging on a Cisco device. Today, I want to show you how to configure the time on a Cisco router or switch.

How to configure the time on a Cisco router
Gulian Technology

It is very important to have the time set up on every device from your network. Accurate timekeeping ensures that logs, events, and network transactions are recorded consistently across the network. It also helps in troubleshooting, security analysis, and compliance audits.

On a Cisco router/switch you can configure the time in 2 modes:

  1. By manually configuring the clock.
  2. By using the NTP protocol.

Configure the time manually

To manually adjust the time on a Cisco router, you can use the following command, replacing “hh:mm:ss” with the desired time. You need also to specify the day of the month, the month and the year.

clock set 10:53:00 20 August 2023
Configure the time manually
Configure the time manually

Check the current time

In order to verify that the time is set up, you need to run the command:

show clock

If you want more details, add the detail keyword to the above command.

Check the current time
Check the current time

Configure NTP

A better approach is to use NTP. As you can see, NTP is not currently configured on my Cisco router.

No NTP running
No NTP running

NTP stands for Network Time Protocol, which is a networking protocol used to synchronize the time of devices on a network. NTP allows devices to maintain accurate and synchronized time by communicating with NTP servers. NTP is sending and receiving timestamps using UDP (User Datagram Protocol) on port number 123.

To configure NTP on a Cisco router, you need to follow these steps.

  1. Access the router’s configuration mode by entering the following command:
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.

2. Specify the NTP server(s) that your router will synchronize with using the ntp server command. You can specify multiple servers for redundancy.

R2(config)#ntp server ?
  A.B.C.D     IP address of peer
  WORD        Hostname of peer
  X:X:X:X::X  IPv6 address of peer
  ip          Use IP for DNS resolution
  ipv6        Use IPv6 for DNS resolution
  vrf         VPN Routing/Forwarding Information

R2(config)#ntp server
Configure the NTP server
Configure the NTP server

Verify that the NTP is running and the time is synchronized to the NTP server

The last step is to verify that the NTP is running and the clock is synchronized to the NTP server.

You can check the status of NTP with 2 commands.

R2#show ntp status
Clock is unsynchronized, stratum 16, no reference clock
nominal freq is 250.0000 Hz, actual freq is 250.0000 Hz, precision is 2**21
ntp uptime is 34600 (1/100 of seconds), resolution is 4000
reference time is 00000000.00000000 (00:00:00.000 UTC Mon Jan 1 1900)
clock offset is 0.0000 msec, root delay is 0.00 msec
root dispersion is 5.18 msec, peer dispersion is 0.00 msec
loopfilter state is 'NSET' (Never set), drift is 0.000000000 s/s
system poll interval is 8, never updated.
Check NTP status
Check NTP status

The second command that you can run is the following:

R2#show ntp associations 

  address         ref clock       st   when   poll reach  delay  offset   disp
 ~   .INIT.          16      -     64     0  0.000   0.000 15937.
 * sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured
Check NTP associations
Check NTP associations

As you can see from the above output, the clock is not synchronized and the stratum level is set to 16. The upper limit for stratum is 15. When you see a lower number in the output it indicates that your device is closer to the atomic clock, which is referenced as stratum 0. The closer you are to stratum 0, the more accurate the time on your device is.

In my lab, the clock is not synchronized because the NTP server is not reachable.

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to, timeout is 2 seconds:
Success rate is 0 percent (0/5)

Below, you can find an output from a Cisco switch where NTP is also configured and the clock is synchronized to the NTP server.

SW2960#show ntp status
Clock is synchronized, stratum 3, reference is
nominal freq is 119.2092 Hz, actual freq is 119.2085 Hz, precision is 2**18
reference time is E88DB060.76A23700 (09:44:00.463 UTC Mon Aug 21 2023)
clock offset is 9.9956 msec, root delay is 15.44 msec
root dispersion is 204.70 msec, peer dispersion is 11.80 msec
SW2960#show ntp associ
SW2960#show ntp associations 

      address         ref clock     st  when  poll reach  delay  offset    disp
*~    2    39    64  377     2.4   10.00    11.8
 * master (synced), # master (unsynced), + selected, - candidate, ~ configured
The clock is synchronized to the NTP server
The clock is synchronized to the NTP server

I hope you find this post useful. Share it on your social media channels so that other people can read it too.

Success! You're on the list.

Leave a Reply