CentOS

Configure Chrony NTP Server on RHEL/Alma/Rocky 9|8

This tutorial will help you install and configure NTP server using Chrony onRHEL/CentOS/Alma/Rocky 9|8. NTP (Network Time Protocol) is a network protocol that allows for clock synchronization between computer systems. Chrony is a versatile implementation of the Network Time Protocol. It has two programs chronyand chronyd.

Original content from computingforgeeks.com - post 5857
  • chronyd is a daemon that can be started at boot time
  • chronyc is a command-line interface program which can be used to monitor chronyd’s performance and to change various operating parameters whilst it is running.

Installing Chrony NTP Server

Set timezone. Replace Africa/Nairobi timezone with your correct value.

sudo timedatectl set-timezone Africa/Nairobi

Chrony can be installed from package manager.

sudo yum -y install chrony

After the installation, start and enable chronyd service.

sudo systemctl enable --now chronyd

The service status should show running

$ systemctl status chronyd
systemctl status chronyd
 chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2024-07-31 15:12:00 EAT; 1s ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 15159 ExecStopPost=/usr/libexec/chrony-helper remove-daemon-state (code=exited, status=0/SUCCESS)
  Process: 15170 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 15164 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 15168 (chronyd)
    Tasks: 1 (limit: 48750)
   Memory: 908.0K
   CGroup: /system.slice/chronyd.service
           └─15168 /usr/sbin/chronyd

Jul 31 15:12:00 rocky8.cloudspinx.com systemd[1]: chronyd.service: Succeeded.
Jul 31 15:12:00 rocky8.cloudspinx.com systemd[1]: Stopped NTP client/server.
Jul 31 15:12:00 rocky8.cloudspinx.com systemd[1]: Starting NTP client/server...
Jul 31 15:12:00 rocky8.cloudspinx.com chronyd[15168]: chronyd version 4.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG)
Jul 31 15:12:00 rocky8.cloudspinx.com chronyd[15168]: Loaded 0 symmetric keys
Jul 31 15:12:00 rocky8.cloudspinx.com chronyd[15168]: Frequency -40.323 +/- 0.052 ppm read from /var/lib/chrony/drift
Jul 31 15:12:00 rocky8.cloudspinx.com chronyd[15168]: Using right/UTC timezone to obtain leap second data
Jul 31 15:12:00 rocky8.cloudspinx.com systemd[1]: Started NTP client/server.

Configuring Chrony NTP Server

After the installation, you can make the changes on Chrony main configuration file /etc/chrony.conf

One main configuration change you can make is to set the time servers closest to you. Since I’m in Nairobi, I’ll set Africa NTP pool of servers.

sudo vi /etc/chrony.conf

Add comment to the first pool line and add a list of NTP servers.

#pool 2.rocky.pool.ntp.org iburst

You can use Global NTP server and the system will try finding the closest available servers for you.

server pool.ntp.org iburst

Optionally select pool based on your geographic location. See all zones in All Pool Servers.

  • Asia
server 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
server 3.asia.pool.ntp.org iburst
  • Africa
server 0.africa.pool.ntp.org iburst
server 1.africa.pool.ntp.org iburst
server 2.africa.pool.ntp.org iburst
server 3.africa.pool.ntp.org iburst
  • Europe
server 0.europe.pool.ntp.org iburst
server 1.europe.pool.ntp.org iburst
server 2.europe.pool.ntp.org iburst
server 3.europe.pool.ntp.org iburst
  • North America
server 0.north-america.pool.ntp.org iburst
server 1.north-america.pool.ntp.org iburst
server 2.north-america.pool.ntp.org iburst
server 3.north-america.pool.ntp.org iburst
  • South America
server 0.south-america.pool.ntp.org iburst
server 1.south-america.pool.ntp.org iburst
server 2.south-america.pool.ntp.org iburst
server 3.south-america.pool.ntp.org iburst

Set NTP synchronization.

sudo timedatectl set-ntp true

Restart chronyd service after making the change.

sudo systemctl restart chronyd

You can also specify IP addresses or network address block that is allowed to access your NTP server.

# Allow NTP client access from local network.
allow 192.168.25.0/24

If you have active firewalld service, allow ntp port.

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

Check if NTP server is working.

$ sudo chronyc sources
 210 Number of sources = 3
 MS Name/IP address         Stratum Poll Reach LastRx Last sample               
 ^+ ntp.dts.mg                    2   7   377   127  +2102us[+1979us] +/-   98ms
 ^* 196.9.24.88                   2   7   377     2    -11ms[  -11ms] +/-  103ms
 ^+ jhb-ntp.mweb.co.za            3   7   377   132    -76us[ +158us] +/-  103ms

Configure NTP Client to use our NTP server

Now that you have Chrony NTP Server installed and configured, you can configure NTP client.

Set timezone.

sudo timedatectl set-timezone Africa/Nairobi

Install chrony and configure it as NTP client.

sudo yum -y install chrony

Edit the configuration file to set NTP server to point your newly configured NTP server.

$ sudo vi /etc/chrony.conf
server 192.168.25.3

Set NTP synchronization.

sudo timedatectl set-ntp true

Start and enable the service.

sudo systemctl enable --now chronyd

Verify the setting using the following command:

$ sudo chronyc sources
 210 Number of sources = 3
 MS Name/IP address                 Stratum Poll Reach LastRx Last sample               
 ^+ 192.168.25.3                    2   7   377    61    +12ms[  +12ms] +/-  100ms

That’s all. You now have NTP server working on RHEL 8 server. See how you can use the timedatectl command to synchronize the system clock with NTP server.

Want an easy to administer RHEL / CentOS / AlmaLinux / Rocky Linux server from a web UI?, check out:

More guides:

Related Articles

CentOS Install Nakivo VMware Backup & Replication tool on Linux CentOS How To Install Linux Kernel 5.17 on CentOS 7 CentOS How to Dual Boot Rocky Linux 10 / AlmaLinux 10 with Windows 11 CentOS How To Install VLC on Fedora 43/42/41/40/39

Leave a Comment

Press ESC to close