Setup NTP Server on Rocky Linux

This article is going to take you through on how to Setup NTP Server on Rocky Linux. NTP is a networking protocol for synchronizing computer clocks across packet-switched, variable-latency data networks. NTP aims to keep all participating computers within a few milliseconds of Coordinated Universal Time (UTC) (UTC).

How to Setup NTP Server on Rocky Linux

  • The ntp package is no longer supported in Rocky Linux, and its functionality is now provided by the chronyd (a user-space daemon) in the chrony package. Use the command below to install NTP server.
sudo yum  install chrony
  • Next, start and enable chrony service using the command below.
sudo systemctl enable --now chronyd
  • It should be up and running, check status using the command below.
systemctl status chronyd

Sample output

● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2022-04-19 21:28:22 EAT; 1h 16min ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
 Main PID: 1041 (chronyd)
    Tasks: 1 (limit: 23385)
   Memory: 1.8M
   CGroup: /system.slice/chronyd.service
           └─1041 /usr/sbin/chronyd

Apr 19 21:28:18 localhost.localdomain systemd[1]: Starting NTP client/server...
Apr 19 21:28:19 localhost.localdomain chronyd[1041]: chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG)
Apr 19 21:28:19 localhost.localdomain chronyd[1041]: Frequency -12.608 +/- 0.452 ppm read from /var/lib/chrony/drift
Apr 19 21:28:19 localhost.localdomain chronyd[1041]: Using right/UTC timezone to obtain leap second data
Apr 19 21:28:22 localhost.localdomain systemd[1]: Started NTP client/server.
Apr 19 21:28:39 localhost.localdomain chronyd[1041]: Selected source 162.159.200.123 (2.pool.ntp.org)
Apr 19 21:28:39 localhost.localdomain chronyd[1041]: System clock TAI offset set to 37 seconds
Apr 19 21:29:46 localhost.localdomain chronyd[1041]: Selected source 160.119.216.197 (2.pool.ntp.org)

Configure NTP server on Rocky Linux

  • Switch to the nearest server pool by editing NTP config file. Check out the closest server pool to your continent in the NTP pool project.
  • Then open the config file with the command below.
sudo nano /etc/chrony.conf
  • replace the existing pools
# Specify one or more NTP servers.
pool 2.pool.ntp.org iburst
  • with one nearest to you. For example Africa/South Africa;
# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
#pool 2.pool.ntp.org iburst
server 0.za.pool.ntp.org
server 1.za.pool.ntp.org
server 2.za.pool.ntp.org
server 3.za.pool.ntp.org
  • Next uncomment the allow configuration directive and set its value to the network or subnet address from which clients are permitted to connect. e.g.
allow 192.168.0.0/24 
  • Save and exit the file.
  • Restart the NTP server using the following command to apply changes.
sudo systemctl restart chronyd

Configure Firewall for NTP server clients

  • Allow NTP on the firewall
firewall-cmd --permanent --add-service=ntp
  • Next reload the firewall to apply the changes
firewall-cmd --reload

Configure NTP Client

  • Install NTP on your client system using the command below.
sudo yum install chrony
  • Next enable chrony to start on boot.
systemctl enable chronyd
  • Then set chrony to act as an NTP client by adding NTP server IP in the /etc/chrony.conf file as shown below.
  • Open /etc/chrony.conf file using your favorite text editor.
sudo nano /etc/chrony.conf
  • Add your server IP in the format below.
Server 192.168.171.128
  • To apply the changes, restart Chrony NTP daemon.
sudo systemctl restart chronyd
  • To see the current time sources (NTP server) that chronyd is accessing, use the following command, which should display NTP server address.
chronyc sources
  • This brings us to the end of our article, congrats!
  • You’ve learnt how to Setup NTP server on Rocky Linux and how to configure a client to use the NTP server for time synchronization.

Read more on NTP Documentation

Other Tutorials

Install Docker CE on Ubuntu 22.04

Install NFS Server on Ubuntu 22.04

Install Anydesk on Rocky Linux

System administrator | Software Developer | DevOps

Leave a Comment