How to Install NTP Server and Client on Rocky Linux using Chrony

In today’s blog we wil guide on How to Install NTP server and Client on Rocky Linux using Chrony. Network Time Protocol, or NTP, is a networking protocol used on computer networks to synchronize time and clocks.

As an alternative to other programs like up, Chrony is an implementation of the Network Time Protocol, or NTP. Operating systems similar to Unix may run Chrony, which is licensed under the GNU GPL v2. Chrony is available for several Linux distributions and is the default NTP server software for some of them.

You can find instructions on how to install and utilize Chrony on the Rocky Linux server in this tutorial. Two distinct methods of using Chrony will be taught to you:

  • NTP Server – Typically, this is the case if you wish to construct a local NTP server. Hence, clients will connect to the local computer running Chrony as NTP Server rather than the public NTP server on the internet.
  • NTP Client – At this point, your computer or client’s time has to be synchronized with an NTP server.

Pre-Requisite

The two separate Rocky Linux servers that will be utilized as an NTP server and NTP client are assumed to exist for the purposes of this guide. Either the most recent version 9, or Rocky Linux v8, can be used. Additionally, on both machines, you will require a non-root user with sudo root rights. If you need support refer How to Install Rocky Linux

Chrony Installation

One way that Unix-like operating systems implement NTP (Network Time Protocol) is using Chrony. The Chrony package may be found by default in the baseos Rocky Linux repository.

Use the dnf command shown below to install the Chrony package.

Once the package is installed now enable and start the services

Configuring Chrony as NTP

This step explains how to configure Chrony on the ROCKY Linux server as an NTP server. We will utilize the Rocky Linux server with the hostname “rocky8” and IP address “192.168.255.126” in this example.

Open ‘/etc/.chrony.conf‘ by running the following line in editor of your choice

You can choose the NTP server source that you wish to utilize on the server directive. The NTP server pool that is closest to you may be found at NTP Pool Project

We’ll utilize the NTP server pool from Asia for this example. Furthermore, we will make advantage of the extra option ‘iburst’, which enables the Chronyd service to refresh the clock for the first time soon after launch.

Remove the comment from the ‘allow‘ directive and include the IP address subnet that is permitted to connect to the NTP server. All clients connected to the network “192.168.2555.0/24” in this example will have access to the NTP server.

Save the file and exit once editing is completed

Let us now restart the Chronyd services

Verify the sources of the NTP server pool

Output

Allow the NTP services in the Firewall for the client to connect

You have now set up and installed Chrony on the Rocky Linux server to function as an NTP server. Next, you may configure Chrony as an NTP client.

Configuring the NTP Client

You will now be able to configure Rocky Linux to use Chrony as an NTP client. In this example, you will configure the hostname ‘ntp-client‘ for the Chrony NTP client on the Rocky Linux computer.

Make sure the client’s computer has the Chrony package installed before you begin. Installing it may be done with the dnf command.

Open the configuration file to edit the NTP servers

Replace the NTP server source on the server directive with the name of your NTP server. The IP address ‘192.168.255.126‘ is being used by the NTP server in this instance.

Here ,

  •  iburst option allows the Chronyd service to make the first update of the clock shortly after the start.
  •  prefer option will prioritize the NTP Server source among other servers without prefer option.

Save the File and exit.

Restart the Chronyd services

Verify the current status of Chrony on the client

ntp-client‘ should be linked to the NTP server ‘192.168.255.126‘, and should have its time synced with it.

Output

The chronyc command below may also be used to confirm the NTP Server sources on the ‘ntp-client‘ system. The NTP Server ‘ntp.hwdomain.io‘ with IP address 192.168.255.126 is now the default and recommended NTP Server source, as you can see on the client computer.

Output

Conclusion

The Rocky Linux server now has the Chrony NTP implementation software installed successfully. Additionally, you learnt how to utilize Chrony for both NTP Server and Client in its most basic form. Finally, you have also learnt how to check the NTP status using the chronyc command line.

Leave a comment