Domain 4IP ServicesCORE

Network Time Protocol (NTP)

Configuring and verifying Network Time Protocol (NTP) to ensure accurate time synchronization across network devices.

Domain: Domain 4: IP Services•Updated: 2026-08-26
#NTP#Time Synchronization#Stratum#Clock Sources#Device Management

Network Time Protocol (NTP) & Time Configuration

Importance of Time Synchronization

  • Concept: Accurate time synchronization across network devices is critical for correlating logs during troubleshooting.
  • Details:
    • Devices use Syslog to record events (interface state changes, OSPF neighbor flaps, reboots).
    • Without synchronized time, correlating logs across multiple devices (e.g., R1 vs R2) is nearly impossible.
    • NTP (Network Time Protocol) automatically synchronizes device clocks over a network, eliminating the drift associated with internal hardware clocks.

Manual Time Configuration

Before NTP, time must be understood. Cisco devices have two separate clocks: the Software Clock (OS time) and the Hardware Clock (Calendar/BIOS time).

  • Software Clock vs Hardware Clock:
    • Software Clock: Maintained by the IOS. Viewed with show clock.
    • Hardware Calendar: Built-in physical clock. Viewed with show calendar. Tracks time even if the device loses power or reboots. Upon reboot, the hardware clock initializes the software clock.
! View software clock and its time source
Router# show clock
Router# show clock detail

! View hardware clock
Router# show calendar

! Manually set software clock (Privileged EXEC mode)
Router# clock set 14:30:00 26 December 2020

! Manually set hardware clock (Privileged EXEC mode)
Router# calendar set 14:30:00 26 December 2020

! Sync hardware clock TO software clock
Router# clock update-calendar

! Sync software clock FROM hardware clock
Router# clock read-calendar

Things to note: clock set and calendar set are done in Privileged EXEC mode and are not saved in the running-config. clock read-calendar is the answer to “how to adjust the software clock to match the hardware clock”.

Time Zone and Daylight Saving Time (DST)

Unlike clock set, time zone and DST configurations are saved in the running-config.

! Configure Time Zone (Global Configuration Mode)
! Syntax: clock timezone <name> <hours-offset> [minutes-offset]
Router(config)# clock timezone JST 9

! Configure Daylight Saving Time (Global Configuration Mode)
! Syntax: clock summer-time <zone> recurring <start-week> <start-day> <start-month> <start-time> <end-week> <end-day> <end-month> <end-time> [offset]
Router(config)# clock summer-time EDT recurring 2 Sunday March 02:00 1 Sunday November 02:00

Things to note: clock timezone and clock summer-time are configured in Global Configuration Mode, NOT Privileged EXEC mode. NTP only operates in UTC; you must manually configure the local time zone on each device.

NTP Basics & Hierarchy

  • Concept: NTP uses a hierarchical structure to distribute time. It operates over UDP Port 123.
  • Accuracy: ~1 millisecond on a LAN, ~50 milliseconds over a WAN/Internet.
  • Stratum Levels:
    • Stratum 0: Highly accurate reference clocks (Atomic clocks, GPS). Not directly reachable over IP.
    • Stratum 1: Primary servers directly connected to Stratum 0 devices.
    • Stratum 2 to 15: Secondary servers syncing from the stratum above them.
    • Maximum Stratum: 15. Anything above 15 is considered unreliable and will not be synced.
graph TD
    A[Stratum 0: Reference Clock Atomic/GPS] --> B[Stratum 1: Primary NTP Server]
    B --> C[Stratum 2: Secondary NTP Server]
    C --> D[Stratum 3: Secondary NTP Server]
    B <-->|Symmetric Active Peer| E[Stratum 2 Peer]

NTP Operating Modes

Mode Description Command
Client (Static Client) Syncs time from an NTP server. ntp server <ip>
Server Provides time to clients. (Automatically enabled if a client successfully syncs to an upstream server). N/A (Automatic)
Symmetric Active (Peer) Peers with devices at the same stratum to share time and provide redundancy. ntp peer <ip>
Master Acts as an NTP server when no external source is available. ntp master [stratum]

NTP Configuration & Verification

Configuring NTP Client

! Configure NTP servers (specify multiple for redundancy)
Router(config)# ntp server 216.239.35.0
Router(config)# ntp server 216.239.35.4
Router(config)# ntp server 216.239.35.8
Router(config)# ntp server 216.239.35.12

! Force the router to prefer a specific server
Router(config)# ntp server 216.239.35.0 prefer

Things to note: The ntp server command places the router in Static Client Mode. The router will dynamically select the best server based on response times, unless prefer is used.

Best Practice: NTP Source Interface

Always use a Loopback interface as the source for NTP packets to ensure reachability even if a physical interface goes down.

! Set the source interface for NTP packets
Router(config)# interface Loopback0
Router(config-if)# ip address 10.1.1.1 255.255.255.255
Router(config)# ntp source Loopback0

NTP Master (No External Source)

If a device cannot reach an external NTP server but needs to provide time to the rest of the network:

! Configure device as an NTP Master (Stratum 8 by default)
Router(config)# ntp master

! Or specify a custom stratum (1-14)
Router(config)# ntp master 9

Things to note: The default stratum for ntp master is 8. When configured, the device uses the internal IP 127.127.1.1 as its reference clock. You cannot manually configure ntp server 127.127.1.1; it only appears this way internally.

Updating the Hardware Calendar

By default, NTP only updates the software clock. To sync the hardware clock:

! Tell the router to update the hardware calendar with NTP time
Router(config)# ntp update-calendar

Verification Commands

! Check NTP associations (servers/peers)
Router# show ntp associations

! Check overall NTP status (sync status, stratum)
Router# show ntp status

show ntp associations Symbols:

Symbol Meaning Description
* sys.peer The device is currently synchronizing to this server.
+ Candidate Server is reachable and a candidate, but not currently selected.
~ Configured Server is configured but not yet reachable/processed.
(None) Outlier/Falseticker Server is deemed inaccurate; device will not sync to it.

NTP Peering (Symmetric Active Mode)

Devices at the same stratum can peer with each other to cross-verify time and provide backup if the upstream server fails.

! Configure R2 and R3 as peers
R2(config)# ntp peer 10.0.23.3
R3(config)# ntp peer 10.0.23.2

NTP Authentication

Optional but recommended. Ensures clients only sync to authorized servers using an MD5 password.

! 1. Enable NTP authentication globally
Router(config)# ntp authenticate

! 2. Create the authentication key (Key number 1, MD5, password 'jeremysitlab')
Router(config)# ntp authentication-key 1 md5 jeremysitlab

! 3. Mark the key as trusted
Router(config)# ntp trusted-key 1

! 4. Apply the key to the NTP server or peer relationship (Client/Peer side only)
Router(config)# ntp server 10.0.12.1 key 1
Router(config)# ntp peer 10.0.23.3 key 1

Things to note: The server itself does not need the ntp server ... key command. Both sides must have the same ntp authentication-key and ntp trusted-key configured.

Comparison Tables

Software Clock vs. Hardware Calendar

Feature Software Clock Hardware Calendar
Command to View show clock show calendar
Command to Set clock set (Privileged EXEC) calendar set (Privileged EXEC)
Persistence Lost on reboot (initialized by hardware) Survives reboots and power loss
NTP Sync Synced by default via NTP Requires ntp update-calendar

NTP Stratum Hierarchy

Stratum Device Type Description
0 Reference Clock Atomic/GPS clocks. Not reachable via IP.
1 Primary Server Directly connected to Stratum 0.
2 - 14 Secondary Server Syncs from the stratum directly above it.
15 Max Stratum Highest reliable stratum.
16 Unsynchronized Device is unsynchronized/unreliable.

Summary of Commands

Manual Time Commands

! View Time
Router# show clock
Router# show clock detail
Router# show calendar
Router# show logging

! Set Time (Privileged EXEC)
Router# clock set 14:30:00 26 December 2020
Router# calendar set 14:30:00 26 December 2020

! Sync Clocks (Privileged EXEC)
Router# clock update-calendar
Router# clock read-calendar

! Time Zone & DST (Global Config)
Router(config)# clock timezone JST 9
Router(config)# clock summer-time EDT recurring 2 Sunday March 02:00 1 Sunday November 02:00

NTP Configuration Commands (Global Config)

! Client Mode
Router(config)# ntp server <ip>
Router(config)# ntp server <ip> prefer

! Master Mode (No external source)
Router(config)# ntp master [stratum 1-14]  ! Default is 8

! Peering (Symmetric Active)
Router(config)# ntp peer <ip>

! Source Interface (Best Practice)
Router(config)# ntp source Loopback0

! Hardware Calendar Sync
Router(config)# ntp update-calendar

! Authentication
Router(config)# ntp authenticate
Router(config)# ntp authentication-key <1-65535> md5 <password>
Router(config)# ntp trusted-key <1-65535>
Router(config)# ntp server <ip> key <1-65535>
Router(config)# ntp peer <ip> key <1-65535>

NTP Verification Commands (Privileged EXEC)

Router# show ntp associations
Router# show ntp status