How To Install NTP (Chrony) On CentOS 8 & RHEL 8

The Network Time Protocol (NTP) is a networking protocol for system clock synchronization with remote internet time servers or other sources such as GPS or radio clocks. Accurate timekeeping is crucial in servers for application to work correctly or troubleshooting issues with the help of logs time stamp.

Chrony is an implementation of NTP, and it is a replacement for the old Ntpd used in previous versions of enterprise Linux operating systems.

Here, we will see how to install NTP (Chrony) On CentOS 8 & RHEL 8

 

Install Chrony On CentOS 8 / CentOS 7 & RHEL 8

There are chances your server already has Chrony installed and configured as a client to use remote clock server(s).

yum install -y chrony
Install Chrony Package
Install Chrony Package

Configure NTP Server Using Chrony

In this section, we will configure the servers as an NTP server, which will act as a remote time server for all clients in your organization.

vi /etc/chrony.conf

Change the subnet value of allow directive as per your requirement to allow the clients from your organization network. In my case, clients who have IP addresses from 192.168.0.1 to 192.168.0.254 are allowed to connect to the NTP server for time synchronization.

allow 192.168.0.0/24

Restart the Chrony service to apply the configuration change.

systemctl restart chronyd

Enable Chrony service on system startup.

systemctl enable chronyd

Add the firewall rules to allow NTP requests from clients.

firewall-cmd --permanent --add-service=ntp

firewall-cmd --reload

Once you have configured the NTP server, go to the client machine and add this server as an NTP server.

Then, run the below command to check how many clients are accessing the NTP server.

chronyc clients
NTP Clients
NTP Clients

Configure NTP Client Using Chrony

Install the Chrony package if the package is not already installed.

yum install -y chrony

Now, we will configure this machine as an NTP client, which will reach the NTP server we configured earlier for time synchronization.

vi /etc/chrony.conf

Comment out the existing server directives and add a new server directive for our NTP server.

server 192.168.0.10
NTP Server
NTP Server

Then, restart the Chrony service.

systemctl restart chronyd

Enable Chrony service on system startup.

systemctl enable chronyd

Check the time source to ensure the client is reaching to correct NTP server.

chronyc sources
Output:

210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? 192.168.0.10                  3   6     1    25  +2525us[+2525us] +/-   87ms
Time Source
Time Source

By default, NTP client will perform a time synchronization every 64 seconds. However, you can adjust the clock manually without waiting for the next time sync polling.

chronyc makestep