Configuring NTP for DNCA on RHEL

You can configure an NTP daemon to synchronize the time of the machine with one or more NTP servers.

First, install the NTP package, which is not included with a minimal installation. After you install the NTP package, select NTP servers, create configuration files, and then enable and start the service.

Table 1. Configuring NTP
Configuration overview Configuration steps
Install the NTP package If you have not done so already, install the NTP package from your Linux distribution.
Select NTP servers

To synchronize your workstation's time, the NTP daemon on your workstation contacts one or more NTP servers specified in the configuration file /etc/ntp.conf.

If an NTP server is not available on the local network, do one of the following steps:

  • Select a public NTP server (visit http://www.ntp.org/ and click Public Time Server Lists). If you select a public NTP server, read the Rules of Engagement (click Rules of Engagement on the main page of the NTP site).
  • Use the NTP time server pool (visit http://www.pool.ntp.org/ and click How do I use pool.ntp.org).

As user root on the workstation, verify that the machine can contact the selected NTP servers. Use the ntpdate command with the query -q option. For example, to query an NTP server whose IP address is 1.2.3.4, use the following command:

ntpdate -q 1.2.3.4

The output must look like the following, which displays the contacted server and the time difference between the local workstation and the server.

server 1.2.3.4, stratum 2, offset 150.695779, delay 0.03366
17 Nov 10:27:09 ntpdate[21597]: step time server 1.2.3.4 offset 150.695779 sec

If the query fails, following output is likely to come:

server 1.2.3.4, stratum 0, offset 0.000000, delay 0.00000
17 Nov 10:29:04 ntpdate[21599]: no server suitable for synchronization found
Create configuration files

Perform the following steps as user root on the machine:

  1. Create file /etc/ntp/step-tickers. You can back up any existing version of the file. The file contains the host names or IP addresses of the NTP servers to contact during startup to initially set the time. If you use the NTP server pool, you must use host names, which requires DNS.

    For example, if the two NTP servers to use are 1.2.3.4 and 5.6.7.8, then use the following commands to create the file:

    echo 1.2.3.4 > /etc/ntp/step-tickers
    echo 5.6.7.8 >> /etc/ntp/step-tickers
    
  2. Create file /etc/ntp.conf with the following commands. You can back up any existing version of the file.
    echo restrict default ignore > /etc/ntp.conf
    echo restrict 127.0.0.1 >> /etc/ntp.conf
    echo driftfile /var/lib/ntp/drift >> /etc/ntp.conf
  3. Add entries by using the restrict and server keywords for each NTP server. The following example adds entries for the hypothetical 1.2.3.4 and 5.6.7.8 NTP servers. The mask, nomodify, notrap, and noquery options prevent the server from modifying the NTP service on the Network Capture host machine.
    nullecho
    restrict 1.2.3.4 mask 255.255.255.255 nomodify notrap noquery >> /etc/ntp.con
    echo server 1.2.3.4 >> /etc/ntp.conf
    echo restrict 5.6.7.8 mask 255.255.255.255 nomodify notrap noquery >> \
    /etc/ntp.con
    echo server 5.6.7.8 >> /etc/ntp.conf
    
Enable and start the NTP service

Perform the following steps as user root on the machine:

  1. Configure the service to start at boot time by using the following command:
    chkconfig ntpd on
  2. Start the service immediately by using the following command:
    service ntpd start
    
  3. Verify that the service started and contacted a server by using the following command:
    ntpq -np
  4. View log messages for the NTP daemon in file /var/log/messages.