Set up NTP Server and Client on AlmaLinux 9

In this guide, we want to teach you How To Set up NTP Server and Client on AlmaLinux 9. A ‘network time server’ is a general description of the software on the NTP- Network Time Protocol server, which is running on any server/computer platform. It is applied to the network appliance (tray mount, rack, etc), which acquires and uses time from an external source to maintain time within its local internal clock, and then supplies the time to its connected network. This is achieved using the NTP or Network Time Protocol.

You can now proceed to the guide steps below on the Orcacore website to complete NTP server and client setup on AlmaLinux 9.

Steps To Set up NTP Server and Client on AlmaLinux 9

To complete this guide, you must log in to your server as a non-root user and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

1. Install Chrony on AlmaLinux 9

To install NTP on your server, you need to have Chrony installed on your server. Chrony is an implementation of the Network Time Protocol and is useful in several ways.

First of all, check the current time zone of your server with the following timedatectl command:

timedatectl

Example output:

Output
Time zone: America/New_York (EDT, -0400)

Next, update your local package index with the following command:

sudo dnf update -y

Then, install Chrony on AlmaLinux 9 with the following command:

sudo dnf install chrony -y

Start and enable your Chrony service with the commands below:

# sudo systemctl start chronyd 
# sudo systemctl enable chronyd

To verify that your Chrony service is active and running on your server, run the command below:

sudo systemctl status chronyd
Set up NTP Server and Client on AlmaLinux 9 - Check Chrony Service Status

2. Configure NTP Server on AlmaLinux 9

The default configuration file for the NTP server is /etc/chrony.conf. First, you need to open the file with your favorite text editor, here we use vi:

sudo vi /etc/chrony.conf

At the file, comment on the Pool line by adding the # from the beginning of the line.

Add a list of NTP servers close to your location. In my case, in the US, you can use the All pool server in the NTPPool website:

#pool 2.cloudlinux.pool.ntp.org iburst
server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org
server 3.us.pool.ntp.org

Also, you need to allow NTP client access from the local network. To do this, edit the line below:

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

When you are done, save and close the file.

In the next step, you need to set NTP synchronization with the following command:

sudo timedatectl set-ntp true

Restart your Chrony service to apply the changes:

sudo systemctl restart chronyd 

Now you can check whether your NTP server is working or not with the following command:

chronyc sources
Check if NTP server is working

At this point, you need to allow NTP service through the AlmaLinux 9 firewall:

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

Reload the firewall to apply the changes:

sudo firewall-cmd --reload

3. Configure NTP Client on AlmaLinux 9

At this point, you need to install the NTP client on a client machine and configure it with Chrony. First, you need to set the correct timezone on your client machine:

sudo timedatectl set-timezone America/New_York

Then, install Chrony on your client machine:

sudo dnf install chrony -y

Edit the configuration file /etc/chrony.conf and point to your NTP server.

sudo vi /etc/chrony.conf
#pool 2.fedora.pool.ntp.org iburst 
server your-server-ip-address

When you are done, save and close the file. Restart your Chrony service to apply the changes:

sudo systemctl restart chronyd

Next, set NTP synchronization:

sudo timedatectl set-ntp true

Enable your Chrony service to start on boot:

sudo systemctl enable chronyd

Now verify your time synchronization:

chronyc sources
Verify time synchronization on AlmaLinux 9

Finally, you can check on NTP clients. To do this, log in to your AlmaLinux 9 server and run the command below:

sudo chronyc clients
Check NTP Clients

That’s it, you are done.

Conclusion

At this point, you have learned to Install and Configure NTP Server and Client on AlmaLinux 9. Setting up NTP on your server ensures accurate and synchronized time across all systems in a network. Time synchronization is crucial for logging, security (e.g., Kerberos), database consistency, and coordination of scheduled tasks.

Hope you enjoy it. You may also like to read the following articles:

Disable NTP Network Time Synchronization on Ubuntu

Update Timezone DB in Linux (tz or zoneinfo)

Set Up Time Synchronization on Debian 12 Bookworm

Share your love

Stay informed and not overwhelmed, subscribe now!