RHEL BasedRocky Linux

How To Setting Up NTP Server and Client on Rocky Linux 9

Setting Up NTP Server and Client on Rocky Linux 9

In this tutorial, we will show you how to setting Up NTP Server and Client on Rocky Linux 9. For those of you who didn’t know, NTP operates on the principle of hierarchical timekeeping using a set of stratum levels. Stratum 0 denotes high-precision reference clocks, such as GPS satellites or atomic clocks. Stratum 1 consists of NTP servers directly connected to stratum 0 sources. Stratum 2 servers synchronize with stratum 1, and the hierarchy continues downwards. NTP Clients, located at the lowest strata, receive time from higher-stratum servers, ensuring a cascading time synchronization mechanism.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step setup NTP Server and Client on Rocky Linux 9 or RHEL-based.

Prerequisites

  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for NTP.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Setting Up NTP Server and Client on Rocky Linux 9

Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:

sudo dnf update
sudo dnf install epel-release

Step 2. Installing NTP on Rocky Linux 9.

Ensure that the NTP package is installed on your Rocky Linux 9 system by running:

sudo dnf install ntp

Step 3. Configuring the NTP Server.

Now that our system is up-to-date and equipped with the necessary packages, let’s proceed with setting up the NTP Server. We choose an appropriate NTP server pool based on your geographical location from the NTP Pool Project’s website. This will help ensure you have access to multiple Stratum 1 servers for enhanced reliability. Visit https://www.ntppool.org/en/ to find the relevant NTP server pool for your region.

Next, open the NTP configuration file using your favorite text editor. In this example, we’ll use nano:

sudo nano /etc/ntp.conf

Locate the “server” section within the configuration file. Replace the existing entries with the chosen NTP server pool addresses. For instance:

server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst

Now, enable and start the NTP service to apply the changes:

sudo systemctl enable ntpd
sudo systemctl start ntpd

Ensure that the NTP service is running and synchronized with external NTP servers by using:

ntpq -p

The output will display the NTP server pool and its status, indicating whether synchronization is established.

Step 4. Setting Up the NTP Client.

With the NTP Server in place, let’s configure the NTP Client to sync with it. First, Identify the IP address or hostname of your NTP Server. You can do this by executing the following command on your NTP Server:

hostname -I

On the NTP Client system, open the NTP configuration file:

sudo nano /etc/ntp.conf

In the configuration file, find the “server” section and replace the default entries with the IP address or hostname of your NTP Server:

server [NTP_SERVER_IP_OR_HOSTNAME] iburst

Enable and start the NTP service on the Client:

sudo systemctl enable ntpd
sudo systemctl start ntpd

Ensure that the NTP Client successfully synchronizes with the NTP Server:

ntpq -p

This command will display a list of the NTP servers that the NTP client is synchronizing with, along with their status and the time offset.

Step 5. Troubleshooting NTP Issues.

Despite its reliability, NTP may encounter occasional issues. Let’s explore some common problems and their potential solutions.

  • Issue 1: NTP Synchronization Failure

Symptom: The NTP Server or Client fails to synchronize with the selected time source.

Solution:

  1. Check the NTP server pool addresses in the configuration files. Ensure that they are correct and accessible.
  2. Verify that your firewall settings permit NTP traffic (UDP port 123) to flow in and out of your system.
  3. Restart the NTP service:
sudo systemctl restart ntpd
  • Issue 2: Clock Drift

Symptom: The system clock continuously drifts away from accurate time.

Solution:

  1. Make sure your system’s hardware clock is accurately set and maintained.
  2. Consider using an external hardware clock source or GPS receiver for better accuracy.

Congratulations! You have successfully installed NTP. Thanks for using this tutorial for installing setup NTP on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official NTP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button