This post will teach you about the Network Time Protocol (NTP), its installation, and its configuration method on CentOS. Furthermore, we will also show you the procedure of setting NTP server and Client on your CentOS system. So let’s head towards this journey!

What is NTP?

The Network Time Protocol: as the name suggests that it is a protocol utilized for synchronizing internal clock timings on a system present in a network. This protocol covers both synchronizing machines on a local network and with an Internet server. It is usually embedded in a client-server setup but can also be used in peer-to-peer time synchronization. The operating system manages timezone, while NTP is used for syncing the Coordinated Universal Time (UTC). Check out the below-given diagram, which represents NTP working:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-1.jpg" data-lazy- height="875" src="data:image/svg xml,” width=”986″>

NTP daemons:

The ntpd daemon, which was used earlier for synchronizing date and time settings, has been declined and is no longer accessible for current Linux systems like Fedora 30, Ubuntu 20.04, and CentOS 8. “Chrony,” a RedHat developed NTP implementation, replaced this NTP daemon.

What is Chrony?

Chrony is a different form of NTP protocol implementation than ntpd. It is configured as NTP Server or an NTP Client. Chrony is made up of two parts:

  1. chronyd: which is a user-space daemon.
  2. chronyc: a command-line application for customizing chronyd.

Compared to chrony, ntpd takes a long time to change the clocks of the systems that are not permanently connected or powered up. The reason behind this fact is that several minor adjustments are performed based on observations of clock offset and drift. The stability of hardware clocks is also influenced by temperature fluctuations, which can be considerable while powering up a machine. In contrast, chrony can adjust to the change the system clock.

What are the things chronyd can do that ntpd cannot do?

  • Chronyd helps you to calculate the gain or loss rate of the hardware or the real-time clock. This segment of chrony can utilize this information to set the system time by retrieving the value from the real-time clock.
  • It also can support isolated networks where the manual entry is only the form of time correction. Chronyd can look at the faults or errors fixed in further updates to estimate how much the computer loses or gains time. After going through this checkpoint, chronyd use the estimate values for trimming the computer clock.

Which NTP daemon should be your choice?

  • All systems that are often disconnected or suspended and then restored to a network should consider chrony. The examples which come under this section are virtual and mobile systems.
  • For systems that are generally left on all the time, the NTP daemon ntpd should be considered. Also, systems that require broadcasting or multi-casting IP should choose to adopt ntpd.

Installing Chrony on CentOS:

Before configuring chrony as an NTP server or Client, you must first ensure that chrony should be installed on your system. If you don’t have it already, write out the below-given command to install it on your CentOS system:

$ sudo dnf install chrony

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-2.png" data-lazy- height="546" src="data:image/svg xml,” width=”737″>

Enter “y” to allow the process to download chrony.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-3.png" data-lazy- height="550" src="data:image/svg xml,” width=”745″>

Once chrony is downloaded, start and then enable the chronyd service by utilizing these commands:

$ systemctl start chronyd

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-4.png" data-lazy- height="299" src="data:image/svg xml,” width=”739″>

$ systemctl enable chronyd

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-5.png" data-lazy- height="303" src="data:image/svg xml,” width=”740″>

Now, check the status of the chronyd service and make sure the service is running.

$ systemctl status chronyd

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-6.png" data-lazy- height="547" src="data:image/svg xml,” width=”742″>

Configuring Chrony as an NTP Server:

We are moving towards the procedure of chrony configuration. Now, we will show you the configuring method of chrony as an NTP Server.


First of all, open up the chrony configuration files in the Vi editor:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-7.png" data-lazy- height="300" src="data:image/svg xml,” width=”741″>

The configuration file will look like this:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-8.png" data-lazy- height="549" src="data:image/svg xml,” width=”742″>

Now, explore this configuration file and uncomment the lines referring to allow the network addresses.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-9.png" data-lazy- height="546" src="data:image/svg xml,” width=”736″>

As the chrony file is opened in a Vi editor, to insert or remove the “#” from the line mentioned above, we have to switch to the Vi insert mode. For that, you have to press “Esc.”

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-10.png" data-lazy- height="551" src="data:image/svg xml,” width=”733″>

If you don’t have the permission to write or change something in the file, utilize the below-given command to change the file permission first.

$ sudo chmod rwx /etc/chrony.conf

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-11.png" data-lazy- height="257" src="data:image/svg xml,” width=”742″>

To save the change and exit the Vi editor, type “:wq” and hit enter.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-12.png" data-lazy- height="478" src="data:image/svg xml,” width=”741″>

Now, restart the chronyd service:

$ systemctl restart chronyd

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-13.png" data-lazy- height="264" src="data:image/svg xml,” width=”742″>

Now, open the firewall port to permit the NTP incoming requests.

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-14.png" data-lazy- height="259" src="data:image/svg xml,” width=”741″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-15.png" data-lazy- height="267" src="data:image/svg xml,” width=”740″>

That’s how you configure an NTP Server in CentOS based on chrony.

Configuring Chrony as an NTP Client:

Do you want to configure chrony as an NTP client rather than an NTP Server? No worries! The upcoming part of the article will demonstrate the method for configuring chrony as an NTP Client.


First of all, install chrony on your CentOS system:

$ sudo dnf install chrony

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-16.png" data-lazy- height="475" src="data:image/svg xml,” width=”737″>

After that, enable the chronyd service by utilizing this command:

$ sudo systemctl enable chronyd

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-17.png" data-lazy- height="263" src="data:image/svg xml,” width=”743″>

Now it’s time to make some changes in the chrony configuration file. These changes are essential for configuring Clients.

$ sudo nano /etc/chrony.conf

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-18.png" data-lazy- height="265" src="data:image/svg xml,” width=”741″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-19.png" data-lazy- height="477" src="data:image/svg xml,” width=”740″>

Add the below-given line in the chrony configuration file and save the changes.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-20.png" data-lazy- height="475" src="data:image/svg xml,” width=”741″>

In the terminal, utilize this command to restart the chronyd service:

$ sudo systemctl restart chronyd

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-21.png" data-lazy- height="259" src="data:image/svg xml,” width=”738″>

Now, check out your NTP sources. Your configured NTP Server should exist in the output list.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/How-to-Configure-NTP-on-CentOS-8-22.png" data-lazy- height="374" src="data:image/svg xml,” width=”742″>

Conclusion:

NTP is a protocol utilized for synchronizing internal clock timings on a system present in a network. This protocol covers both synchronizing machines on a local network and with an Internet server. Earlier systems used ntpd daemon as NTP implementation, but this NTP daemon has been declined and is no longer accessible for the latest Linux systems, including CentOS 8. Chrony is deployed in the market as a replacement for the ntpd daemon. In this article, you learned some basic stuff about NTP, chrony, and its features. Furthermore, we have also shown you the methods for configuring chrony as an NTP server and Client on your CentOS system.

About the author

<img alt="" data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/talha-150×150.jpg" height="112" src="data:image/svg xml,” width=”112″>

Talha Saif Malik

Talha is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.