NTP Commands
Network Time Protocol (NTP) is designed to synchronize the clock over the network. The protocol is build on top of the User Datagram Protocol (UDP). In the most common mode of operation, a client sends an NTP message to one or more servers and processes the replies as received. From the replies, the client extracts the time information and applies corrections to the local clock.
Time corrections are applied gradually, it may take several hours until the frequency error is compensated. The final achievable accuracy depends on the time source being used, and it varies with network delays. A time difference of less than 128ms between server and client is required to maintain NTP synchronization.
RCP100 implements both the client and the server functionality. The server listens on UDP port 123 which is the standard NTP port.
Table Of Contents
ip ntp serverntp server
show ntp associations
show ntp status
Example
ip ntp server
Enable NTP server.
ip ntp server
no ip ntp server
ntp server
Set an external NTP server to synchronize to.
ntp server <hostname>
ntp server <IP address>
no ntp server <hostname>
no ntp server <IP address>
no form of the command removes the server.
Example:
rcp(config)#ntp server 64.73.32.135 rcp(config)#ntp server 108.61.73.243 rcp(config)#ntp server 64.6.144.6
show ntp associations
Show the status of NTP associations.
show ntp associations
Example:
rcp#show ntp associations Peer Status Stratum Offset Delay Interval clock.nyc.he.net active 1 3.406355s 7.189118s 324s 128.233.154.245 active 1 -0.152589s 0.140479s 323s rcp#
show ntp status
Show the NTP synchronization status.
show ntp status
Example:
rcp#show ntp status Clock is not synchronized Reference is 209.51.161.238, reference time is 3543144343.660823 Clock offset is 0.016887s, root delay is 0.046622s rcp#
Example
In this example, RCP100 is connecting the office network on interface eth0, where it is set to act as an NTP server for all the computers on this network. It can reach the Internet on interface eth1. NTP server functionality on interface eth1 is disabled using an Access Control List. The ACL prohibits access to UDP port 123 on this interface.
access-list 100 deny udp any any 123 ! ip ntp server ! interface ethernet eth0 ip address 10.10.0.1/16 ip mtu 1500 no shutdown ! interface ethernet eth1 ip address 10.20.0.10/16 ip mtu 1500 ip access-group 100 in no shutdown !
RCP100 synchronizes the clock to three external NTP servers. The relevant configuration is as follows:
rcp(config-if eth0)#show configuration ntp ntp server 64.73.32.135 ntp server 108.61.73.243 ntp server 64.6.144.6 ip ntp server ! rcp(config-if eth0)#
www.pool.ntp.org lists thousands of public NTP servers you can use for synchronization. Try to chose servers as close to you as possible. Using "show ntp associations" you can check the connection to your servers:
The interval specifies how often each server is contacted, in our case about every 30 seconds. The offset is the time difference between our clock and the server clock. Once the offset drops below 128ms, our clock will be declared synchronized. The adjusting process is slow, in this case it will take at least one hour to synchronize the clock.rcp(config)#show ntp associations Peer Status Stratum Offset Delay Interval 64.73.32.135 active 2 -2.562777s 0.274973s 32s 108.61.73.243 active 2 -2.652763s 0.070802s 34s 64.6.144.6 active 2 -2.668991s 0.090640s 34s rcp(config)#
rcp(config)#show ntp status Clock is not synchronized Reference is 64.6.144.6, reference time is 3541669890.021777 Clock offset is -2.668991s, root delay is 0.090640s rcp(config)#
One hour later, the clock is synchronized and the slow process of synchronizing the office network clients starts.
rcp(config)#show ntp associations Peer Status Stratum Offset Delay Interval 64.73.32.135 active 2 0.198416s 0.906080s 277s 108.61.73.243 active 2 0.082141s 0.625836s 273s 64.6.144.6 active 2 -0.212892s 0.094471s 288s rcp(config)#show ntp status Clock is synchronized, stratum 3 Reference is 108.61.73.243, reference time is 3541679227.911409 Clock offset is -0.050216s, root delay is 0.057396s rcp(config)#