In today’s interconnected digital world, accurate timekeeping is crucial for network operations, security, and synchronization. The Network Time Protocol (NTP) plays a vital role in maintaining precise time across computer networks. For system administrators and IT professionals managing AlmaLinux 8 servers, setting up an NTP server is an essential task that ensures all systems in the network operate on the same timeline.
AlmaLinux 8, a robust and stable RHEL-based distribution, provides an excellent platform for hosting an NTP server. This guide will walk you through the process of installing and configuring an NTP server using Chrony on AlmaLinux 8. Chrony, a versatile implementation of the NTP, offers improved accuracy and reliability compared to traditional NTP daemons.
By the end of this tutorial, you’ll have a fully functional NTP server running on your AlmaLinux 8 system, capable of synchronizing time across your network infrastructure. Let’s dive into the step-by-step process of setting up this critical network service.
Prerequisites
Before we begin the installation process, ensure that you have the following:
System Requirements:
- A machine running AlmaLinux 8
- Minimum of 1 GB RAM
- At least 10 GB of available disk space
User Permissions:
- Root access or a non-root user with sudo privileges
Network Configuration:
- A basic understanding of network settings
- A stable internet connection for initial time synchronization
With these prerequisites in place, you’re ready to proceed with the installation and configuration of your NTP server.
Step 1: Update System Packages
Before installing any new software, it’s crucial to ensure your system is up-to-date. This practice helps prevent compatibility issues and ensures you have the latest security patches.
To update your AlmaLinux 8 system, open a terminal and run the following command:
sudo dnf update
This command will refresh your package lists and upgrade all installed packages to their latest versions. If prompted, enter your sudo password and confirm the updates.
Keeping your system updated is not just a prerequisite for this installation; it’s a best practice for maintaining the security and stability of your AlmaLinux 8 server. Regular updates help protect against vulnerabilities and ensure optimal performance.
Step 2: Install Chrony NTP Server
Chrony is the default NTP implementation in AlmaLinux 8, offering improved accuracy and reliability over older NTP daemons. It’s particularly well-suited for systems with intermittent network connections or those that don’t run continuously.
To install Chrony, execute the following command:
sudo dnf install chrony
The package manager will resolve dependencies and prompt you to confirm the installation. Type ‘y’ and press Enter to proceed.
Once the installation is complete, you can verify the installed version of Chrony by running:
chronyd -v
This command will display the version information, confirming that Chrony is successfully installed on your system.
Step 3: Configure Chrony NTP Server
With Chrony installed, the next step is to configure it to act as an NTP server. The main configuration file for Chrony is located at /etc/chrony.conf
. We’ll need to modify this file to set up our NTP server correctly.
Open the configuration file using a text editor of your choice. For this example, we’ll use nano:
sudo nano /etc/chrony.conf
In this file, you’ll find several pre-configured settings. Let’s go through the key modifications:
1. NTP Pool Servers:
By default, Chrony is configured to use the NTP pool servers. These lines typically look like:
pool 2.almalinux.pool.ntp.org iburst
You can keep these default pools or add your preferred NTP servers. For example, to use CentOS NTP pools, you might add:
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
The ‘iburst
‘ option speeds up the initial synchronization process.
2. Allow Network Access:
To allow other machines on your network to synchronize their time with your NTP server, add the following line:
allow 192.168.1.0/24
Replace ‘192.168.1.0/24
‘ with your actual network range. This line allows time synchronization requests from the specified network.
3. Local Stratum:
If you want your server to act as a time source when it’s not synchronized with upstream servers, add:
local stratum 10
This sets the stratum to 10, indicating it’s a lower-priority time source.
After making these changes, save the file and exit the text editor. In nano, you can do this by pressing Ctrl+X, then Y, and finally Enter.
Step 4: Start and Enable Chrony Service
Now that we’ve configured Chrony, it’s time to start the service and ensure it starts automatically on system boot.
To start the Chrony service, run:
sudo systemctl start chronyd
To enable Chrony to start on boot, use:
sudo systemctl enable chronyd
You can verify the status of the Chrony service with:
sudo systemctl status chronyd
This command will display the current status of the Chrony service. Look for “Active: active (running)” to confirm that the service is running correctly.
Step 5: Configure Firewall
For your NTP server to be accessible to other machines on the network, you need to configure the firewall to allow NTP traffic. AlmaLinux 8 uses firewalld as its default firewall management tool.
To open the NTP port (123) in the firewall, run:
sudo firewall-cmd --permanent --add-service=ntp
This command adds a permanent rule to allow NTP traffic. To apply the changes, reload the firewall:
sudo firewall-cmd --reload
You can verify the firewall configuration by listing all the allowed services:
sudo firewall-cmd --list-all
In the output, you should see ‘ntp’ listed under the ‘services’ section, confirming that NTP traffic is now allowed through the firewall.
Step 6: Verify NTP Server Configuration
With the NTP server installed, configured, and the firewall adjusted, it’s time to verify that everything is working as expected.
To check the NTP sources your server is using, run:
chronyc sources
This command displays a list of the current time sources. You should see the NTP pools you configured earlier in the list.
To verify the current time synchronization status, use:
chronyc tracking
This command provides detailed information about the system’s time synchronization, including the reference ID of the current time source, the stratum, and the estimated error in the system clock.
Troubleshooting Common Issues
Even with careful setup, you might encounter some issues. Here are solutions to common problems:
1. Chrony Service Not Starting:
If the Chrony service fails to start, check the system logs for more information:
journalctl -xe | grep chronyd
This command will display recent log entries related to the Chrony service, which can help identify the cause of the problem.
2. Time Not Synchronizing:
If your server isn’t synchronizing time properly, verify your network connectivity and check your /etc/chrony.conf
file for any misconfigurations. Ensure that the NTP ports are not blocked by your firewall or ISP.
3. Clients Unable to Sync:
If other machines on your network can’t synchronize with your NTP server, double-check your firewall settings and the ‘allow’ directive in your Chrony configuration.
Advanced Chrony Features
Chrony offers several advanced features that can enhance your NTP server’s functionality:
1. NTP Authentication:
For increased security, you can set up NTP authentication. This prevents unauthorized time sources from affecting your server’s time. Add the following to your /etc/chrony.conf
:
keyfile /etc/chrony.keys
ntpsigndsocket /var/lib/samba/ntp_signd/
Then create and manage keys in the /etc/chrony.keys
file.
2. Leap Second Handling:
Chrony can handle leap seconds smoothly. The following configuration enables this feature:
leapsecmode slew
maxslewrate 1000
smoothtime 400 0.001 leaponly
3. Hardware Timestamping:
If your network interface supports hardware timestamping, you can enable it for improved accuracy:
hwtimestamp *
Remember to restart the Chrony service after making any configuration changes.
Congratulations! You have successfully installed NTP. Thanks for using this tutorial for installing NTP Server on your AlmaLinux 8 system. For additional help or useful information, we recommend you to check the official Chrony website.