# NTP Configuration Tasks

By default, the system is an NTP client. You must configure NTP client parameters to start NTP client operation. You can also configure the system as an NTP server, whether or not you configure NTP client parameters.

## Enabling NTP Services

Before you can configure NTP client parameters or enable a virtual router to act as an NTP server, you must enable NTP services. When you enable NTP services, the NTP client associates itself with the current virtual router. Because there is only one system clock to update, only the virtual router on which you configure NTP can act as the NTP client. However, any virtual router can act as an NTP server. To enable NTP services:

1. (Optional) Access the virtual router with which you want to associate NTP services.
2. Issue the ntp enable command.

ntp enable

- Use to enable NTP services on the system.
- This command associates NTP services and the NTP client with the current virtual router.
- Example
  host1:boston(config)#ntp enable
- Use the no version to disable NTP polling and clock correction and to remove the association between NTP services and the virtual router.
- See ntp enable.

## NTP Client Configuration

To configure the system as an NTP client:

1. Ping the selected NTP servers to ensure that the system can reach them.
2. Configure the system to acquire NTP data by completing one or both of the following actions:
   - Assign the NTP servers.
   - Enable the system to receive broadcasts on an interface.
3. If you enable the system to receive broadcasts on an interface, set the estimated round-trip delay between the system and an NTP broadcast server.
4. Disable NTP on interfaces that you do not want to receive NTP communications for security or other reasons.

ntp broadcast-client

- Use to enable the system to receive NTP broadcasts on an interface.
- Example
  host1(config-if)#ntp broadcast-client
- Use the no version to prevent the system from receiving NTP broadcasts.
- See ntp broadcast-client.

ntp broadcast-delay

- Use to set the estimated round-trip delay in the range 0 to 999,999 microseconds between the system and an NTP broadcast server.
- Example
  host1(config)#ntp broadcast-delay 2000
- Use the no version to set the estimated round-trip delay to the default, 3000 microseconds.
- See ntp broadcast-delay.

ntp disable

- Use to disable NTP on an interface.
- Example
  host1(config-if)#ntp disable
- Use the no version to reenable NTP on an interface.
- See ntp disable.

ntp server

- Use to assign an NTP server to the system and to customize the way the server communicates with the system.
- Specify the source option to direct responses from the NTP server to a specific interface on the system and override the ntp source command.
- Example
  host1(config)#ntp server 192.35.42.1 version 3 prefer source atm 3/0.1
- Use the no version to terminate communications between the system and an NTP server.
- See ntp server.

ping

- Use to check that the system can reach an NTP server.
- Example
  host1(config)#ping 192.35.42.1
- There is no no version.
- See ping.

### Directing Responses from NTP Servers

By default, an NTP server sends a response to the interface from which an NTP request originated. You can now direct responses from all NTP servers to one interface on the system or direct responses from a specific NTP server to a specific interface.

ntp source

- Use to direct responses from all NTP servers to a specific interface. Using the source option with the ntp server command overrides the ntp source command.
- Example
  host1(config)#ntp source atm 3/1
- Use the no version to direct all servers to reply to the interface from which the NTP request was sent (the default setting).
- See ntp source.

### Refusing Broadcasts from NTP Servers

You can prevent the system from receiving certain types of broadcasts and specify the servers from which the system will accept NTP broadcasts. To do so:

1. Issue the ntp access-group command.
2. Configure an access list.

access-list

- Use to configure an access list.
- Example
  host1(config)#access-list europe permit any
- Use the no version to remove the access list.
- See access-list.

ntp access-group

| Note: The system can accept, but does not use, NTP control queries.

- Use to specify the types of broadcasts that the system will accept and respond to, and to specify an access list of servers from which the system will accept broadcasts.You can enable the system to:
  - Receive time requests, receive NTP control queries, and synchronize itself to the servers specified on the access-list
  - Only receive time requests and NTP control queries from specified servers
  - Only receive time requests from specified servers
  - Only receive NTP control queries from specified servers
- Example
  host1(config-line)#ntp access-group peer europe
- Use the no version to enable the system to receive all NTP broadcasts on interfaces configured to receive broadcasts.
- See ntp access-group.

## NTP Server Configuration

To enable a virtual router to act as an NTP server:

1. Access the virtual router context.
2. Specify that the virtual router acts as an NTP server.

   | Caution: Be sure that you do not override a valid time source if you specify the stratum of the NTP server. Issuing the ntp master command on multiple systems in the network might lead to unreliable timestamps if those systems do not agree on the time.

3. (Optional) Specify the stratum of this NTP server.

ntp broadcast

- Use to enable broadcast server on an interface to send NTP broadcast messages periodically.
- The server sends the NTP broadcast messages to the local network broadcast address (255.255.255.255).
- Example—In this example, the interface supports NTP software, version 4, and a poll interval of 5 (32 seconds) for broadcasting NTP messages.
  host1:boston(config-if)#ntp broadcast version 4 5
- Use the no version to prevent the interface from sending NTP broadcast messages.
- See ntp broadcast.

ntp master

- Use to specify the stratum number of a virtual router you configured as an NTP server
- By default, the stratum number is set to the stratum number of the master plus one.

  | Caution: Although you can specify a stratum number of 1, the system does not support stratum 1 service. The system can synchronize only with an NTP server, and not directly with an atomic clock or radio clock.

- Specify a stratum number for the system in the range 1 – 15. A stratum n server is n hops from an accurate time source.
- Example
  host1:boston(config)#ntp master
- Use the no version to restore the default stratum number.
- See ntp master.

ntp server enable

- Use to enable a virtual router to act as an NTP server.
- Example
  host1:boston(config)#ntp server enable
- Use the no version to prevent a virtual router from acting as an NTP server.
- See ntp server enable.

## Configuration Examples

The following examples show how to configure the system as an NTP client and an NTP server.

Example 1

NTP communications are established on the virtual router boston. The system is a client of the NTP server with IP address 172.16.5.1.

host1#virtual-router boston host1:boston#ping 172.16.5.1 Sending 5 ICMP echos to 172.16.5.1, timeout = 2 sec......Success rate = 100% (0/5), round-trip min/avg/max = 0/0/0 ms host1:boston#configure terminal host1:boston(config)#ntp server 172.16.5.1 host1:boston(config)#ntp enable

Example 2

NTP communications are established on the virtual router boston. The system is specified as an NTP server.

host1#virtual-router boston host1:boston#configure terminal host1:boston(config)#ntp server

Example 3

NTP communications are established on the virtual router boston. The router is specified as an NTP broadcast server and synchronizes with NTP server 172.16.5.1. The specified interface enabled for NTP broadcasting is configured with version 4 and poll interval 5 for broadcasting NTP messages.

host1#virtual-router boston host1:boston#configure terminal host1:boston#ntp enable host1:boston(config)#ntp server 172.16.5.1 host1:boston(config)#interface fastethernet 9/3 host1:boston(config-if)#ntp broadcast 4 5

| Note: In Example 3, the router that acts as the NTP broadcast server must either synchronize to another server or master (specified by the ntp server command) or act as master (ntp master command).