NTP Server Configuration


You want to configure the NTP server to provide time to your routers.


To configure an NTP server to provide time to your network, use the commands in Example 14-1.

Example 14-1. /etc/ntp.conf

#Define NTP Servers
#Define Access Control
restrict nomodify notrap nopeer noquery
restrict nomodify notrap nopeer noquery
restrict nomodify notrap nopeer noquery
#Define NTP Drift File 
driftfile /var/log/ntp.drift

The NTP servers used in this example are fictitious. Please read the Discussion section to learn how to locate publicly available NTP servers.



To find publicly available NTP servers to synchronize to, perform an nslookup on domain name pool.ntp.org. This DNS entry contains a number of Stratum 2 NTP servers that have agreed to participate in the DNS round robin group. Please be sure to perform the nslookup yourself to ensure you choose active and accurate NTP servers. The ones listed in the following example may have grown stale since the publication of this book:

Freebsd% nslookup pool.ntp.org
Server: dns.oreilly.com

Non-authoritative answer:
Name: pool.ntp.org


We strongly recommend that you use the IP addresses, since the restrict commands will not work with DNS names. The restrict commands define access control. For more information on access control commands, please see the manpages for ntp.conf.

Once configured and launched, you can monitor the current status of your NTP server by using the ntpq command. One of the most useful command options is ntpq p, which shows you the current status of the server and its configured NTP servers:

Freebsd% ntpq -p
 remote refid st t when poll reach delay offset jitter
+ .GPS. 1 u 479 1024 177 97.930 -0.552 13.109
* .USNO. 1 u 527 1024 377 41.933 1.565 2.462
+ .WWV. 1 u 442 1024 377 0.956 -0.259 0.668

As you can see, the three fictitious NTP servers are all active and reachable. We can also tell by the "*" that our server is synchronized to server, which is a Stratum 1 server, as listed in the "st" column. The other two servers are selected for possible synchronization, as denoted by the "+". For a complete listing of NTP status codes, please see Table 14-2 or the ntpq manpage.

To enable MD5 authentication on the server, so that your routers can access it securely, you must first create one or more keys in the NTP key file called /etc/ntp.keys (Example 14-2).

Example 14-2. /etc/ntp.keys

2 M oreilly
3 M testing

In this example, we have created two MD5 keys, 2 and 3. Although the server will support other authentication methods, Cisco IOS only supports MD5 keys. The MD5 keys must be entered as clear text and must match the key(s) listed in your router configuration.

Once you have created your NTP keys, you must configure the server to enable authentication by modifying the ntp.conf file:

#Define NTP Servers
#Define Access Control
restrict nomodify notrap nopeer noquery
restrict nomodify notrap nopeer noquery
restrict nomodify notrap nopeer noquery
#Define NTP Drift File 
driftfile /var/log/ntp.drift
#Enable Authorization
enable auth
keys /etc/ntp.keys
trustedkey 2

In this example, we have highlighted the authentication portion of the ntp.conf file. As you can see, we have enabled authentication by using the enable auth command. We then defined where the NTP key file is located, and finally we enabled key number 2 as our trusted key. Once the NTP daemon is restarted, the server is ready to provide authenticated access to the routers.

The following example shows how to configure a router to securely access our server using NTP authentication. Please note that the authentication key number and password must be the same as the one configured in the server to work:

Router#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ntp authentication-key 2 md5 oreilly
Router(config)#ntp authenticate
Router(config)#ntp trusted-key 2
Router(config)#ntp server key 2

For more information on configuring the router for NTP authentication, please see Recipe 14.12 or the ntp.conf manpage.

See Also

Recipe 14.12; Recipe 14.16

Router Configuration and File Management

Router Management

User Access and Privilege Levels


IP Routing





Frame Relay

Handling Queuing and Congestion

Tunnels and VPNs

Dial Backup

NTP and Time


Router Interfaces and Media

Simple Network Management Protocol





First Hop Redundancy Protocols

IP Multicast

IP Mobility




Appendix 1. External Software Packages

Appendix 2. IP Precedence, TOS, and DSCP Classifications


show all menu

Cisco IOS Cookbook
Cisco IOS Cookbook (Cookbooks (OReilly))
ISBN: 0596527225
EAN: 2147483647
Year: 2004
Pages: 505
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net