Configuring NTP

This chapter contains the following sections:

Information about NTP

The Network Time Protocol (NTP) synchronizes timekeeping among a set of distributed time servers and clients. This synchronization allows you to correlate events when you receive system logs and other time-specific events from multiple network devices.

NTP uses the User Datagram Protocol (UDP) as its transport protocol. All NTP communication uses the Universal Time Coordinated (UTC) standard. An NTP server usually receives its time from an authoritative time source, such as a radio clock or an atomic clock attached to a time server. NTP distributes this time across the network. NTP is extremely efficient; no more than one packet per minute is necessary to synchronize two machines to within a millisecond of each other.

NTP uses a stratum to describe how many NTP hops away that a network device is from an authoritative time source. A stratum 1 time server has an authoritative time source (such as an atomic clock) directly attached to the server. A stratum 2 NTP server receives its time through NTP from a stratum 1 NTP server, which in turn connects to the authoritative time source.

NTP avoids synchronizing to a network device that may keep accurate time. NTP never synchronizes to a system that is not synchronized itself. NTP compares the time reported by several network devices and does not synchronize to a network device that has a time that is significantly different than the others, even if its stratum is lower.

Cisco NX-OS cannot act as a stratum 1 server. You cannot connect to a radio or atomic clock. We recommend that the time service that you use for your network is derived from the public NTP servers available on the Internet.

If the network is isolated from the Internet, Cisco NX-OS allows you to configure a network device so that the device acts as though it is synchronized through NTP, when it has determined the time by using other means. Other network devices can then synchronize to that network device through NTP.


Note


NTP supports IPv4 addresses.


NTP Peers

NTP allows you to create a peer relationship between two networking devices. A peer can provide time on its own or connect to an NTP server. If both the local device and the remote peer point to different NTP servers, your NTP service is more reliable. The local device maintains the right time even if its NTP server fails by using the time from the peer.

The following figure shows a network with two NTP stratum 2 servers and two switches.

Figure 1. NTP Peer and Server Association

In this configuration, switch 1 and switch 2 are NTP peers. switch 1 uses stratum-2 server 1, while switch 2 uses stratum-2 server 2. If stratum-2 server-1 fails, switch 1 maintains the correct time through its peer association with switch 2.

High Availability

Stateless restarts are supported for NTP. After a reboot or a supervisor switchover, the running configuration is applied.

You can configure NTP peers to provide redundancy in case an NTP server fails.

Prerequisites for NTP

You must have connectivity to at least one server that is running NTP.

Guidelines and Limitations for NTP

  • You should have a peer association with another device only when you are sure that your clock is reliable (which means that you are a client of a reliable NTP server).

  • A peer configured alone takes on the role of a server and should be used as a backup. If you have two servers, you can configure several devices to point to one server and the remaining devices point to the other server. You can then configure a peer association between these two servers to create a more reliable NTP configuration.

  • If you only have one server, you should configure all the devices as clients to that server.

  • You can configure up to 64 NTP entities (servers and peers).

Default Settings for NTP

Parameter

Default

NTP

Enabled

Configuring an NTP Server and Peer

You can configure NTP using IPv4 addresses or domain name server (DNS) names.

Before You Begin

Before beginning this procedure, you must be logged in to the CLI in EXEC mode.

Procedure
     Command or ActionPurpose
    Step 1 switch# configure terminal 

    Places you in global configuration mode.

     
    Step 2switch(config)# ntp server {ip-address | dns-name} 

    Forms an association with a server.

     
    Step 3switch(config)# ntp peer {ip-address | dns-name} 

    Forms an association with a peer. You can specify multiple peer associations.

     
    Step 4switch(config)# show ntp peers  (Optional)

    Displays the configured server and peers.

    Note   

    A domain name is resolved only when you have a DNS server configured.

     
    Step 5switch(config)# copy running-config startup-config  (Optional)

    Saves the running configuration persistently through reboots and restarts by copying it to the startup configuration.

     
    switch# configure terminal
    switch(config)# ntp server 192.0.2.10
    switch(config# ntp peer 2001:0db8::4101

    Clearing NTP Sessions

    Command

    Purpose

    clear ntp session

    Clears the NTP sessions.

    Clearing NTP Statistics

    Command

    Purpose

    clear ntp statistics

    Clears the NTP sessions.

    Verifying the NTP Configuration

    Use one of the following commands to verify the configuration:

    Command

    Purpose

    show ntp peer-status

    Displays the status for all NTP servers and peers.

    show ntp peers

    Displays all the NTP peers.

    show ntp statistics {io | local | memory | peer {ip-address | dns-name}

    Displays the NTP statistics.

    NTP Example Configuration

    This example configures an NTP server:

    Procedure
      Step 1   switch# configure terminal

      Enters global configuration mode.

      Step 2   ntp server 192.0.2.10

      Configures an NTP server.


      Feature History for NTP

      Feature Name

      Releases

      Feature Information

      NTP

      4.0(4)SV1(1)

      This feature was introduced.