Use the commands in this topic to configure NTP servers.
Note
See Configuring NTP authentication using the CLI for information about ensuring that the system clocks are only updated if the time is obtained from a trusted source.
Go to CLI configuration mode:
hostname > enable hostname # configure terminal
Enable NTP synchronization:
hostname (config) # ntp enableSpecify the primary NTP server:
hostname (config) # ntp server <server>where
<server>is the IPv4 or IPv6 address, or hostname of the NTP server.Repeat the previous step for the secondary NTP server and any additional NTP servers.
Specify the version:
hostname (config) # ntpTo change the version on an NTP server:
hostname (config) ntp server <server> version <version>where
<server>is the IPv4 or IPv6 address, or hostname of the NTP server, and<version>is either 3 or 4To change the version on an NTP peer:
hostname (config) ntp peer <peer> version <version>where
<peer>is the IPv4 or IPv6 address, or hostname of the NTP peer, and<version>is either 3 or 4.Save your changes:
hostname (config) # write memory
Disable NTP synchronization:
hostname (config) # ntp disableor
hostname (config) # no ntp enableSave your changes:
hostname (config) # write memory
Synchronize the system time:
hostname (config) # ntpdate <server>where
<server>is the IPv4 or IPv6 address, or hostname of the NTP server to synchronize with.Save your changes:
hostname (config) # write memory
Go to CLI standard mode.
View the information:
hostname > show ntp
Go to CLI standard mode.
View the information:
hostname > show ntp configured
Examples
The following example configures two NTP servers and an NTP peer.
hostname (config) # ntp server 0.acme.pool.ntp.org hostname (config) # ntp server 1.acme.pool.ntp.org hostname (config) # ntp peer 5.acme.pool.ntp.org hostname (config) # show ntp configured NTP enabled: yes NTP Authentication enabled: yes NTP peer 5.acme.pool.ntp.org Enabled: yes NTP version: 4 Key: none NTP server 0.acme.pool.ntp.org Enabled: yes NTP version: 4 Key: none NTP server 1.acme.pool.ntp.org Enabled: yes NTP version: 4 Key: none
The following example disables NTP synchronization on the system.
hostname (config) # no ntp enable hostname (config) # show ntp configured NTP enabled: no NTP Authentication enabled: yes No NTP peers configured. NTP server 0.acme.pool.ntp.org Enabled: yes ... hostname (config) # show ntp NTP is administratively disabled. NTP Authentication is administratively enabled. Clock is unsynchronized. No NTP associations present.
The following example temporarily disables NTP on the "3.acme.pool.ntp.org" server.
hostname (config) # ntp server 3.acme.pool.ntp.org disable hostname (config) # show ntp configured NTP enabled: yes NTP Authentication enabled: yes No NTP peers configured. NTP server 0.acme.pool.ntp.org Enabled: yes ... NTP server 3.acme.pool.ntp.org Enabled: no ...
The following example removes the "2.acme.pool.ntp.org" NTP server.
hostname (config) # no ntp server 2.acme.pool.ntp.orgThe following example synchronizes the system clock with the NTP server.
hostname (config) # ntpdate 0.acme.pool.ntp.org
adjust time server 192.168.120.23 offset -0.023716 secThe following example changes the NTP version on the "3.acme.pool.ntp.org" server to version 3.
hostname (config) # ntp server 3.acme.pool.ntp.org version 3 hostname (config) # show ntp configured NTP enabled: yes NTP Authentication enabled: yes No NTP peers configured. ... NTP server 3.acme.pool.ntp.org Enabled: yes NTP version: 3 Key: none
The following example shows the current NTP runtime state and configuration.
hostname > show ntp
NTP is administratively enabled.
NTP Authentication is administratively enabled.
Clock is synchronized. Reference: 10.255.34.6 Offset: 1.713 ms.
Active servers and peers:
Poll Last
Conf Offset Ref Interv Resp
Address Type Status Stratum (msec) Clock (sec) (sec)
===========================================================================
192.168.1.1 n/a candidat (+) 2 -0.233 10.2.3.4 64 60
10.2.3.4 n/a outlyer (-) 2 12.069 192.168.2.2 64 50
172.16.4.5 n/a candidat (+) 2 -0.958 10.5.6.7 64 50
10.255.34.6 n/a sys.peer (*) 2 1.713 172.16.3.4 64 45The following example shows the configured NTP servers and their settings:
hostname > show ntp configured
NTP enabled: yes
NTP Authentication enabled: yes
No NTP peers configured.
NTP server 0.acme.pool.ntp.org
Enabled: yes
NTP version: 4
NTP server 1.acme.pool.ntp.org
Enabled: yes
NTP version: 4
NTP server 2.acme.pool.ntp.org
Enabled: yes
NTP version: 4
NTP server 3.acme.pool.ntp.org
Enabled: yes
NTP version: 4