How To Install NTP (Chrony) On CentOS 8 / CentOS 7 & RHEL 8 / RHEL 7 | Holhol24

48

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 /
CentOS 7 &
RHEL 8 /
RHEL 7.

Chrony works as the default NTP server and client on CentOS 8 / RHEL 8. In CentOS 7/ RHEL 7, you have an option to choose either NTP or Chrony as an NTP daemon.

Install Chrony On CentOS 8 / CentOS 7 & RHEL 8 / RHEL 7

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

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 How To Install NTP (Chrony) On CentOS 8 / CentOS 7 &  RHEL 8 / RHEL 7 | Holhol24 How To Install NTP (Chrony) On CentOS 8 / CentOS 7 &  RHEL 8 / RHEL 7 | Holhol24 1605829897 705 How To Install NTP Chrony On CentOS 8 CentOS
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 How To Install NTP (Chrony) On CentOS 8 / CentOS 7 &  RHEL 8 / RHEL 7 | Holhol24 How To Install NTP (Chrony) On CentOS 8 / CentOS 7 &  RHEL 8 / RHEL 7 | Holhol24 1605829897 248 How To Install NTP Chrony On CentOS 8 CentOS
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 How To Install NTP (Chrony) On CentOS 8 / CentOS 7 &  RHEL 8 / RHEL 7 | Holhol24 How To Install NTP (Chrony) On CentOS 8 / CentOS 7 &  RHEL 8 / RHEL 7 | Holhol24 1605829897 295 How To Install NTP Chrony On CentOS 8 CentOS
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

Conclusion

That’s All. Please share your feedback in the comments section.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More