Configuring NTP servers using the CLI

Prev Next

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.

To enable and configure NTP servers:
  1. Go to CLI configuration mode:

    hostname > enable
    hostname # configure terminal
  2. Enable NTP synchronization:

    hostname (config) # ntp enable
  3. Specify the primary NTP server:

    hostname (config) # ntp server <server>

    where <server> is the IPv4 or IPv6 address, or hostname of the NTP server.

  4. Repeat the previous step for the secondary NTP server and any additional NTP servers.

To change the NTP version:
  1. Specify the version:

    hostname (config) # ntp
  2. To 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 4

  3. To 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.

  4. Save your changes:

    hostname (config) # write memory
To disable NTP:
  1. Disable NTP synchronization:

    hostname (config) # ntp disable

    or

    hostname (config) # no ntp enable
  2. Save your changes:

    hostname (config) # write memory
To synchronize the system time with a specific NTP server one time:
  1. 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.

  2. Save your changes:

    hostname (config) # write memory
To view the current NTP runtime state and configuration:
  1. Go to CLI standard mode.

  2. View the information:

    hostname > show ntp
To view the configured NTP servers and their settings:
  1. Go to CLI standard mode.

  2. 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.org

The 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 sec

The 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     45

The 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