CentOS / Red Hat Configure an NTP Client And Server

To configure an NTP client and server on CentOS or Red Hat Linux, follow these steps:

  1. Install the NTP package on the server:
    sudo yum install ntp
  2. Edit the NTP configuration file /etc/ntp.conf:
    sudo nano /etc/ntp.conf
  3. In the server section, add one or more NTP servers that the client should synchronize with. For example, to synchronize with the NTP pool servers, add the following lines:
    server 0.centos.pool.ntp.org
    server 1.centos.pool.ntp.org
    server 2.centos.pool.ntp.org
    server 3.centos.pool.ntp.org

    You can also specify your own NTP server, if you have one.

  4. Save and exit the file.
  5. Start the NTP service:
    sudo systemctl start ntpd
  6. Enable the NTP service to start automatically at boot time:
    sudo systemctl enable ntpd
  7. To verify that the client is synchronizing with the NTP server, use the ntpq command:
    ntpq -p

    This will show a list of the NTP servers that the client is synchronizing with, along with their status and the current offset.

To configure an NTP server, follow these additional steps:

  1. Edit the NTP configuration file /etc/ntp.conf:
    sudo nano /etc/ntp.conf
  2. In the server section, add the iburst option to the server line to improve synchronization speed:
    server 127.127.1.0 iburst

    This specifies that the local clock should be used as a reference clock.

  3. Save and exit the file.
  4. Start the NTP service:
    sudo systemctl start ntpd
  5. Enable the NTP service to start automatically at boot time:
    sudo systemctl enable ntpd

That’s it! You have now configured an NTP client and server on CentOS or Red Hat Linux. Note that the client and server can be the same machine, in which case it will synchronize with itself.

Leave a Comment