CentOS

How to Set Up Chrony on CentOS 8

What is Chrony?

Chrony is another implementation of the Network Time Protocol (NTP). It’s used to synchronize time and clocks from different NTP servers, reference clocks, and manual input.

Chrony can be used as an NTPv4 server (the RFC 5905), which provides a time service to other computers in the network. It’s provides two different programs, the chronyd which is the service daemon and the chronyc the command-line interface for configuring Chrony.

What we will do

In this tutorial, you will learn how to set up Chrony on CentOS 8 Server. You will learn how to install and configure Chrony as an NTP Server. Also, using the Chrony as NTP Client.

Prerequisites

For this tutorial, make sure you have got a CentOS 8 server with root privileges.

Below is the tutorial about the CentOS 8 server installation.

Install CentOS 8 Server

Before going any further, log in to your CentOS server and type the sudo command to get the root privileges on your system.

sudo su

Step 1 – Install Chrony on CentOS 8

First, you will install Chrony and it’s dependencies on the CentOS system. And by default, the chrony packages are available on the CentOS BaseOS repository.

Install chrony using the dnf command below.

dnf install chrony

After that, start the chrony service and add it to the system boot.

systemctl start chronyd
systemctl enable chronyd

The chrony service is up and running, check it using the command below.

chronyc activity

As a result, you’ve installed Chrony on CentOS 8 Server.

Install Chrony on CentOS 8

Step 2 – Set Up Chrony NTP Server

In this step, you will change the default NTP pool of chrony and set up chrony as an NTP server.

On the CentOS system, the chrony configuration is located at ‘/etc/chrony.conf’. Edit the chrony configuration using vim editor.

vim /etc/chrony.conf

– Change Default NTP Pool

The NTP Pool is a collection of computer servers provided by volunteers to provide highly accurate time synchronization via the Network Time Protocol (NTP) to clients worldwide.

It’s recommended to use the NTP pool nearest to your zone, you can find the NTP pool based on your zone here.

Now change the default NTP pool with your nearest zone and make the configuration as below.

pool 0.jp.pool.ntp.org iburst maxsources 2
pool 1.jp.pool.ntp.org iburst maxsources 2
pool 2.jp.pool.ntp.org iburst maxsources 2
pool 3.jp.pool.ntp.org iburst maxsources 2

Save and close.

As a result, you’ve changed the default NTP pool with your nearest zone.

– Enable Local Server

Next, you will make the server as an NTP server for all clients on the same local network.

Add the following configuration and change the server IP addresses with your own.

allow 192.168.56.102/24
allow 192.168.56.10

Save and close.

Now restart the chrony service with the command below.

systemctl restart chronyd

As a result, you’ve created an NTP server for your local network with Chrony.

Change NTP Pool and Enable NTP Server Chrony

Step 3 – Setup Client with Chronyd

In this step, you will set up an NTP client with Chrony, ane makes sure you have got the chrony packages installed on your client machines.

To set up the NTP client, edit the chrony configuration ‘/etc/chrony.conf’ using vim editor.

vim /etc/chrony.conf

Now change the default NTP pool with the configuration and below, and change the NTP server IP address with your own.

server 192.168.56.101 prefer iburst

Save and close.

After that, restart the Chrony service.

systemctl restart chronyd

As a result, you’ve set up and NTP client using Chrony on the CentOS system.

Setup Chrony Client CentOS

Step 4 – Testing

In this step, you will learn the ‘chronyc’ command to check the NTP server and clients.

– Check Time Sources for NTP

To check the current sources of the NTP server used by the chronyd service, use the ‘sources’ option as below.

chronyc sources

Below is the result you will get.

Show NTP Sources

For details status, add the ‘-v’ option (as verbose).

chronyc sources -v

Below are the details of NTP sources.

Show NTP Sources Details

Additionally, below are the result of the same command on the NTP Client machine.

Show NTP Sources Details on the Client Side

– Check Clients Connected to the NTP Server

As you run the NTP server for your local network clients, check clients’ IP addresses which connected to the NTP server using the ‘chronyc’ command below.

chronyc clients

As a result, your clients have been connected to the local NTP server which you just set up on top.

Checking Chrony Client

Finally, you’ve successfully set up both the NTP server and client using Chrony on CentOS 8 Server.

Write A Comment