Linux

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

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

Network Time Protocol (NTP) is a network protocol for synchronizing system clocks with remote internet time servers or other sources such as GPS or radio clocks. Accurate timeliness is very important in the server so that the application functions properly or resolves problems with the help of log timestamps.

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

Here, we will see how to install NTP (Chrony) on CentOS 8 / CentOS 7 & RHEL 8 / RHEL 7.

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

It is possible that your server has installed and configured Chrony as a client to use the remote clock server.

yum install -y chrony

1

Install Chrony Package

Configure NTP Server Using Chrony

In this section, we will configure the server 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 from the allow directive according to your needs to allow clients from your organization’s network. In my case, clients who have IP addresses from 192.168.0.1 through 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 configuration changes.

systemctl restart chronyd

Enable the Chrony service at system startup.

systemctl enable chronyd

Add firewall rules to allow NTP requests from clients.

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

firewall-cmd --reload

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

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

chronyc clients

2

NTP Clients

Configure NTP Client Using Chrony

Install the Chrony package if the package has not been installed.

yum install -y chrony

Now, we will configure this machine as an NTP client, which will reach the NTP server that we configured before to synchronize the time.

vi /etc/chrony.conf

Comment on the existing server directives and add new server directives for our NTP server.

server 192.168.0.10

3

NTP Server

Then, restart the Chrony service.

systemctl restart chronyd

Enable the Chrony service at system startup.

systemctl enable chronyd

Check the time source to make sure the client reaches to repair the 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

4

Time Source

By default, the NTP client will synchronize the time every 64 seconds. However, you can adjust the clock manually without waiting for the next synchronization poll.

chronyc makestep

Conclusion

That is all. Please share your feedback in the comments section.

Related posts

How to call a function in Python

Linux

How to Install Drupal 9 with Nginx and Let’s Encrypt SSL on Debian 10

Linux

How to Upgrade From Windows 7 to Linux

Howto

Fedora 31: How to Install Fuel CMS with Nginx

Howto

How to Install Microsoft TrueType Fonts on Fedora

Linux

How to Monitor CPU Usage in Linux Over Time

Linux

How to install Steam and activate Proton on Fedora

Linux

How to Install Matrix Synapse Chat on Ubuntu 20.04 LTS

Linux

How to Install Ruby On Rails on Ubuntu 20.04

Linux