NTP Configuration
Every log message, security event, and diagnostic output on a Cisco device includes a timestamp. If device clocks are not synchronised, those timestamps are meaningless — a syslog message on R1 timestamped 09:00 and a related message on R2 timestamped 11:47 cannot be correlated even if both events happened simultaneously. Inaccurate time also breaks AAA authentication (Kerberos tickets), SSL/TLS certificate validation, and SSH session establishment.
NTP (Network Time Protocol) synchronises device clocks across a network to a common time reference with millisecond accuracy. One device acts as the authoritative time source — all others synchronise to it. NTP uses a hierarchical model called stratum — the closer a device is to the atomic reference clock, the lower (and more accurate) its stratum number. For a conceptual overview see NTP and NTP Synchronisation.
Before starting, ensure IP connectivity between devices is established — NTP uses UDP port 123 and requires a routed path to the NTP server. Complete OSPF Single-Area Configuration or Static Route Configuration for the routing prerequisite. For viewing timestamped logs after NTP is configured, see show logging.
1. NTP — Core Concepts
Why Accurate Time Matters
| Function | Impact of Wrong Time | Impact of Correct Time |
|---|---|---|
| Syslog & logging | Log timestamps are wrong — events cannot be correlated across devices during incident response | All log entries across all devices share a common timeline — instant event correlation. See Syslog Configuration |
| SSH / TLS | Certificate validity checks fail — connections refused if device clock is outside the certificate validity window | Certificate dates validated correctly — secure connections established. See SSH Configuration |
| AAA / Kerberos | Authentication tickets rejected — device clock more than 5 minutes off causes Kerberos to fail | Ticket timestamps valid — seamless authentication. See AAA Overview |
| Debugging | Packet captures and debug outputs across multiple devices have mismatched times — root cause analysis is difficult | All devices share the same clock — debug sequences line up perfectly |
| Compliance | Audit logs with wrong timestamps fail regulatory requirements (PCI-DSS, HIPAA, ISO 27001) | Accurate audit trails satisfy compliance requirements |
NTP Stratum Hierarchy
NTP uses a stratum number (1–15) to represent distance from the reference clock. Stratum 0 devices are the atomic or GPS clocks themselves — they are not network-accessible. Stratum 1 servers connect directly to a Stratum 0 device. Each hop away from the reference adds one to the stratum number:
Stratum 0 ── Atomic / GPS clock (not a network device)
↓
Stratum 1 ── Public NTP servers (time.google.com, pool.ntp.org)
↓ directly connected to atomic clock
Stratum 2 ── Your ISP's NTP server / enterprise NTP server
↓ synchronised to Stratum 1
Stratum 3 ── R1 configured as ntp master (Cisco IOS)
↓ synchronised to Stratum 2, serves internal network
Stratum 4 ── R2, R3, Switches — NTP clients of R1
synchronised to R1
Stratum 16 ── Unsynchronised (default until NTP sync achieved)
| Stratum | Meaning | Accuracy |
|---|---|---|
| 1 | Directly connected to atomic/GPS reference clock | Microseconds |
| 2–4 | One to three hops from reference — typical enterprise range | Milliseconds |
| 5–15 | Further from reference — acceptable for most network devices | Tens of milliseconds |
| 16 | Unsynchronised — device has not yet synchronised or has lost its NTP source | Unreliable |
NTP Modes — Client, Server, and Peer
| Mode | IOS Command | Role | Direction |
|---|---|---|---|
| Client | ntp server [IP] |
Synchronises its clock to the specified NTP server — the most common mode | Receives time only |
| Master | ntp master [stratum] |
Acts as an authoritative NTP source for other devices — uses its own hardware clock as the reference. Used when no external NTP server is available | Provides time to clients |
| Peer | ntp peer [IP] |
Bidirectional synchronisation — both devices can synchronise to each other. Used for redundancy between NTP servers | Both sends and receives |
2. Lab Topology & Scenario
NetsTuts_R1 is the edge router with internet access. It synchronises to a public NTP server (time.google.com / 216.239.35.0) and also acts as the internal NTP master for the rest of the network. NetsTuts_R2 and NetsTuts_SW1 are NTP clients of R1. All devices use UTC timezone with timezone offsets configured locally:
Public Internet
216.239.35.0 (time.google.com — Stratum 1)
|
NTP sync (UDP/123)
|
┌──────────────────────────┐
│ NetsTuts_R1 │
│ ntp server 216.239.35.0 │ ← NTP client to Google
│ ntp master 3 │ ← Internal NTP server (Stratum 3)
│ Stratum: 2 after sync │
└──────────────────────────┘
| |
NTP client NTP client
(UDP/123) (UDP/123)
| |
┌──────────────┐ ┌──────────────┐
│ NetsTuts_R2 │ │ NetsTuts_SW1 │
│ ntp server │ │ ntp server │
│ 10.0.12.1 │ │ 10.0.12.1 │
│ Stratum: 3 │ │ Stratum: 3 │
└──────────────┘ └──────────────┘
All devices: UTC timezone
R1 also configured as NTP master (stratum 3) for lab fallback
| Device | NTP Role | NTP Source | Expected Stratum |
|---|---|---|---|
| NetsTuts_R1 | Client to Google + Master for internal | 216.239.35.0 (external) | 2 (after syncing to Stratum 1) |
| NetsTuts_R2 | NTP Client | 10.0.12.1 (R1) | 3 |
| NetsTuts_SW1 | NTP Client | 10.0.12.1 (R1) | 3 |
3. Step 1 — Set Timezone and Configure Logging Timestamps
Before configuring NTP, set the timezone on every device. Without a timezone, all devices default to UTC — which is correct for centralised logging but may not match local display preferences. Also enable timestamp precision on log messages so every log entry carries full date and time detail after NTP synchronises:
NetsTuts_R1>en NetsTuts_R1#conf t Enter configuration commands, one per line. End with CNTL/Z. ! ── Set timezone — UTC+3 (Arabian Standard Time example) ─ NetsTuts_R1(config)#clock timezone AST 3 ! ── Optional: Configure daylight saving time ───────────── ! NetsTuts_R1(config)#clock summer-time AST recurring ! ── Enable detailed timestamps on all log messages ─────── NetsTuts_R1(config)#service timestamps log datetime msec show-timezone NetsTuts_R1(config)#service timestamps debug datetime msec show-timezone
service timestamps log datetime msec show-timezone adds
full date, time with milliseconds, and timezone label to every syslog
message. Without this, IOS log messages show only relative uptime
(e.g., "00:15:32") which is useless for cross-device correlation.
msec adds millisecond precision — valuable during
incident response when events happen within the same second.
4. Step 2 — Configure R1 as NTP Client and Internal Master
R1 performs two NTP roles simultaneously: it is a client
to the public NTP server (synchronising its own clock) and a
master for internal devices (providing time to R2 and SW1).
The ntp master command creates a fallback — if the external
NTP server is unreachable, R1 uses its own hardware clock as the source
at the configured stratum:
! ── Synchronise R1 to Google's public NTP server ───────── NetsTuts_R1(config)#ntp server 216.239.35.0 prefer NetsTuts_R1(config)#ntp server 216.239.35.4 ! ── R1 acts as internal NTP master at stratum 3 ────────── ! ── (fallback if external NTP unreachable) ─────────────── NetsTuts_R1(config)#ntp master 3 ! ── Use loopback as NTP source interface ───────────────── NetsTuts_R1(config)#ntp source Loopback0 ! ── Optional: Restrict who can query R1's NTP service ──── NetsTuts_R1(config)#ntp access-group serve-only 10 NetsTuts_R1(config)#access-list 10 permit 192.168.0.0 0.0.255.255 NetsTuts_R1(config)#access-list 10 permit 10.0.0.0 0.255.255.255 NetsTuts_R1(config)#end NetsTuts_R1#wr Building configuration... [OK] NetsTuts_R1#
prefer marks
216.239.35.0 as the primary choice. If it becomes unreachable, IOS
automatically falls back to 216.239.35.4. The ntp source Loopback0
command ensures NTP packets sourced from R1 always use the loopback IP
— a stable, always-up address that other devices use as the NTP server
target. The ntp access-group serve-only restricts NTP
service to only internal subnets, preventing external hosts from using
R1 as a public NTP server.
ntp master — Stratum Selection
| Command | Stratum Assigned | When to Use |
|---|---|---|
ntp master 1 |
Stratum 1 | Never — stratum 1 implies a directly connected atomic clock. Do not claim stratum 1 without a real reference. |
ntp master 2 |
Stratum 2 | Only if R1 synchronises to a verified Stratum 1 server and the accuracy is confirmed |
ntp master 3 |
Stratum 3 | ✅ Standard internal NTP master — clients become Stratum 4. Accurate enough for all enterprise purposes |
ntp master 8 |
Stratum 8 | Lab-only fallback — high stratum signals low authority. Clients synchronise but treat it as a last-resort source |
5. Step 3 — Configure R2 and SW1 as NTP Clients
Internal devices only need the ntp server command pointing
to R1's IP. Using R1's loopback IP as the NTP server address is best
practice — it remains reachable as long as R1 is running, regardless
of which physical interface connects R2 to R1:
NetsTuts_R2
NetsTuts_R2>en NetsTuts_R2#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_R2(config)#clock timezone AST 3 NetsTuts_R2(config)#service timestamps log datetime msec show-timezone NetsTuts_R2(config)#service timestamps debug datetime msec show-timezone ! ── Point to R1's loopback as NTP server ───────────────── NetsTuts_R2(config)#ntp server 1.1.1.1 prefer NetsTuts_R2(config)#ntp server 10.0.12.1 NetsTuts_R2(config)#end NetsTuts_R2#wr Building configuration... [OK] NetsTuts_R2#
NetsTuts_SW1 (Layer 2 / Layer 3 Switch)
NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_SW1(config)#clock timezone AST 3 NetsTuts_SW1(config)#service timestamps log datetime msec show-timezone NetsTuts_SW1(config)#service timestamps debug datetime msec show-timezone ! ── Use management VLAN IP to reach R1's NTP ───────────── NetsTuts_SW1(config)#ntp server 1.1.1.1 prefer NetsTuts_SW1(config)#ntp server 10.0.12.1 NetsTuts_SW1(config)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
6. Step 4 — NTP Authentication (Security Hardening)
Without NTP authentication, any device that can reach the NTP port can send false time updates — an attacker who manipulates device clocks can invalidate certificates, corrupt audit logs, and break time-sensitive security mechanisms. NTP MD5 authentication ensures clients only accept time from verified servers:
Configure NTP Authentication on R1 (Server)
NetsTuts_R1(config)#ntp authenticate NetsTuts_R1(config)#ntp authentication-key 1 md5 NetsTutsNTP2026 NetsTuts_R1(config)#ntp trusted-key 1
Configure NTP Authentication on R2 (Client)
NetsTuts_R2(config)#ntp authenticate NetsTuts_R2(config)#ntp authentication-key 1 md5 NetsTutsNTP2026 NetsTuts_R2(config)#ntp trusted-key 1 NetsTuts_R2(config)#ntp server 1.1.1.1 key 1
ntp authenticate enables the authentication requirement,
ntp authentication-key [id] md5 [password] defines the
shared key, and ntp trusted-key [id] marks which key IDs
are acceptable. On the client, the key [id] appended to
the ntp server command tells IOS which key to use when
communicating with that specific server. The key ID and password must
match exactly on both devices.
NTP Authentication Command Summary
| Command | Where | Purpose |
|---|---|---|
ntp authenticate |
Server + Client | Enables NTP authentication — without this, keys are defined but not enforced |
ntp authentication-key [id] md5 [pass] |
Server + Client | Defines the shared secret key identified by a number (1–4294967295) |
ntp trusted-key [id] |
Server + Client | Marks which key IDs are trusted — packets signed with untrusted keys are rejected |
ntp server [IP] key [id] |
Client only | Associates a specific key with a specific NTP server — client uses this key to authenticate with that server |
7. Step 5 — Manual Clock (Lab / No External NTP)
In lab environments where no internet access or external NTP server is
available, the hardware clock can be set manually. A manually set clock
has no automatic drift correction — use ntp master on at
least one device to serve as the authoritative time source for all others:
! ── Set hardware clock manually (privileged EXEC) ──────── ! ── Format: hh:mm:ss Day Month Year ────────────────────── NetsTuts_R1#clock set 09:00:00 5 March 2026 ! ── Verify immediately ─────────────────────────────────── NetsTuts_R1#show clock 09:00:03.214 AST Thu Mar 5 2026 ! ── Sync hardware clock to NTP-sourced software clock ──── NetsTuts_R1#ntp update-calendar
clock set sets the software clock in RAM — it resets if the
router loses power without a battery. ntp update-calendar
writes the current software clock (sourced from NTP) to the hardware
calendar (NVRAM-backed) — this persists across power cycles.
In production, always run ntp update-calendar after NTP
synchronises so rebooted devices start with a close-to-accurate time
before NTP re-synchronises.
8. Verification
show ntp status — R1
NetsTuts_R1#show ntp status Clock is synchronized, stratum 2, reference is 216.239.35.0 nominal freq is 250.0000 Hz, actual freq is 249.9991 Hz, precision is 2**18 ntp uptime is 3600 (1/100 of seconds), resolution is 4000 reference time is E8F3A201.B4E2C000 (09:00:01.706 AST Thu Mar 5 2026) clock offset is 0.4573 msec, root delay is 14.23 msec root dispersion is 7.88 msec, peer dispersion is 1.64 msec loopfilter state is 'CTRL' (Normal Controlled Loop), drift is -0.000009138 s/s system poll interval is 64, last update was 42 sec ago.
show ntp status — R2 (Client)
NetsTuts_R2#show ntp status Clock is synchronized, stratum 3, reference is 1.1.1.1 nominal freq is 250.0000 Hz, actual freq is 249.9993 Hz, precision is 2**18 reference time is E8F3A209.C1F40000 (09:00:09.757 AST Thu Mar 5 2026) clock offset is 0.8821 msec, root delay is 22.15 msec root dispersion is 12.42 msec, peer dispersion is 2.11 msec loopfilter state is 'CTRL' (Normal Controlled Loop), drift is -0.000003241 s/s system poll interval is 64, last update was 18 sec ago.
show ntp associations
NetsTuts_R1#show ntp associations address ref clock st when poll reach delay offset disp *~216.239.35.0 .GOOG. 1 41 64 377 14.23 0.457 1.64 +~216.239.35.4 .GOOG. 1 102 64 377 15.81 0.621 1.97 * sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured
show ntp associations — R2
NetsTuts_R2#show ntp associations address ref clock st when poll reach delay offset disp *~1.1.1.1 216.239.35.0 2 28 64 377 7.91 0.882 2.11 +~10.0.12.1 216.239.35.0 2 55 64 377 8.14 0.901 2.34 * sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured
show clock detail
NetsTuts_R1#show clock detail 09:05:42.318 AST Thu Mar 5 2026 Time source is NTP
show clock detail adds the Time source line —
confirming where the current time came from. Possible values: NTP
(synchronised — correct), user configuration (manually set
with clock set — not NTP-synchronised), or hardware
calendar (read from NVRAM calendar at boot — not yet NTP-synced).
Only NTP confirms active synchronisation.
Verification Command Summary
| Command | What It Shows | Key Indicator |
|---|---|---|
show ntp status |
Synchronisation state, stratum, reference server, offset, delay | "Clock is synchronized" = NTP working. "Clock is unsynchronized" = NTP not yet complete or failed |
show ntp associations |
All configured NTP servers — reachability (reach), selected peer (*), stratum, offset, delay | * = current peer, reach 377 = fully reachable, reach 000 = unreachable |
show clock detail |
Current time, timezone, and time source | "Time source is NTP" = actively synchronised. Any other source = not NTP-synchronised |
show clock |
Current time and date — quick check | Verify time is correct after synchronisation |
show logging |
Log messages with timestamps — verify timestamps show correct date/time format after NTP sync | Log entries should show full datetime (not uptime) after service timestamps log datetime |
show ip sockets |
UDP/123 listening socket — confirms NTP process is active and listening | UDP/123 entry present = NTP service running |
9. Troubleshooting NTP Issues
| Problem | Symptom | Cause | Fix |
|---|---|---|---|
| "Clock is unsynchronized" persists | show ntp status keeps showing "Clock is unsynchronized" even after 10+ minutes |
NTP server unreachable — routing or ACL blocking UDP/123, wrong server IP, or NTP server is down | Ping the NTP server IP from the router. Verify UDP/123 is not blocked by an ACL. Check show ntp associations — if reach shows 000 the server is not responding. Try a different NTP server. |
| reach shows 000 in associations | show ntp associations shows reach = 000 for all configured servers |
No NTP responses received — UDP/123 blocked, no route to server, or server IP is wrong | Verify routing to the NTP server IP with ping [NTP-server-IP] source [interface]. Check for ACLs blocking UDP/123 with show ip access-lists. Confirm the correct NTP server IP in config. |
| NTP authentication failure | Associations show status "x" (falseticker) or client does not sync despite reaching server | Authentication key or key ID mismatch between server and client — the server sends a different key or key ID than the client trusts | Verify both devices use identical key ID and password: show running-config | include ntp auth. The key ID number and MD5 password must match exactly. Also confirm ntp trusted-key [id] is configured on both. |
| Wrong timezone displayed | show clock shows correct UTC time but wrong local time |
clock timezone not configured or set to wrong offset |
Configure the correct offset: clock timezone [NAME] [hours] [minutes]. For UTC+3: clock timezone AST 3. NTP itself always works in UTC — the timezone setting only affects display. |
| Log timestamps still showing uptime format | Syslog messages show "00:15:32" instead of "09:05:42 Mar 5 2026" | service timestamps log datetime not configured — default is uptime format |
Add service timestamps log datetime msec show-timezone in global config. Existing log entries in the buffer will not be updated — only new messages use the new format. |
| R1 NTP master not serving clients | R2 and SW1 show "Clock is unsynchronized" even though R1 is configured as master | ntp master configured on R1 but ntp source interface is down, or the NTP access-group ACL is blocking client IPs |
Verify R1's loopback or source interface is up. Check ntp access-group ACL permits the client IPs. Verify R2 can reach R1's IP on UDP/123. |
Key Points & Exam Tips
- NTP synchronises device clocks to a common time source using UDP port 123. Accurate time is essential for log correlation, SSH/TLS certificate validation, AAA authentication, and compliance audit trails.
- Stratum represents distance from the atomic reference clock. Stratum 1 = directly connected to atomic/GPS. Each hop adds 1. Stratum 16 = unsynchronised. Lower stratum = more accurate and more trusted.
ntp server [IP]configures a device as an NTP client.ntp master [stratum]makes a device an authoritative NTP source for other devices.ntp peer [IP]creates bidirectional synchronisation between two NTP servers.ntp master 3is the standard internal NTP master configuration — use stratum 3 so clients become stratum 4. Never configure stratum 1 unless a real atomic clock is connected.- Use R1's loopback IP as the NTP source and as the NTP server address on clients — loopbacks are always up, making NTP resilient to physical interface failures.
service timestamps log datetime msec show-timezonemust be configured on every device to add accurate date/time to log messages. Without it, logs show relative uptime — useless for multi-device correlation.- NTP authentication (
ntp authenticate,ntp authentication-key,ntp trusted-key) prevents rogue time sources from injecting false timestamps. The key ID and MD5 password must match exactly on server and client. - In
show ntp associations: the asterisk (*) marks the active synchronisation peer, reach 377 (octal) means all 8 recent polls were successful, reach 000 means the server is unreachable. show ntp statusis the primary verification command — "Clock is synchronized" confirms NTP is working.show clock detailadds the time source — "Time source is NTP" is the expected value.- On the CCNA exam: know the difference between
ntp server(client mode),ntp master(server mode), andntp peer(bidirectional), what stratum numbers mean, and how to readshow ntp statusandshow ntp associationsoutput.