install ntp server in linux

How to Install NTP in RHEL/CentOS

NTP (Network Time Protocol) is a system clock synchronizer for computers on a network. It synchronizes computer clocks to internet time or other sources. It can also be used as time server for client/server systems. Since RHEL 8, NTP is implemented by chronyd daemon installed as a part of chrony package. Chrony works as both ntp server & client. You can use it to synchronize clocks with manual input or to a peer-to-peer network. In this article, we will look at how to install & configure NTP server & client using chrony package.


How to Install NTP in RHEL/CentOS

Here are the steps to install NTP server in RHEL/CentOS. We will use the following client & server IPs.

NTP Server - RHEL 8:  192.168.48.120
NTP Client - CentOS 7:  192.168.48.129


1. Install Chrony in RHEL

Open terminal on server machine, and run the following command to install chrony package in RHEL.

# dnf install chrony

It consists of a daemon, chronyd, and a configuration tool, chronyc. Next, run the following commands to start, enable autostart, and get status of chronyd.

# systemctl start chronyd
# systemctl status chronyd
# systemctl enable chronyd


2. Configure Chrony in RHEL

Open /etc/chrony.conf in text editor.

# sudo vi /etc/chrony.conf

Look for allow configuration directive and update the network or subnet address from where clients are allowed to connect.

allow 192.168.48.0/24

Save and close the file. Restart chronyd service to apply changes.

# systemctl restart chronyd

Update firewalld configuration to allow incoming access to NTP server.

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


3. Install Chrony Client in RHEL

Install chrony on client by running following command.

# yum install chrony

As done on server machine above, run the following commands to start, enable autostart and get status of chrony daemon.

# systemctl start chronyd
# systemctl status chronyd
# systemctl enable chronyd


4. Configure Chrony client

Open /etc/chrony.conf file on client system, using a text editor.

# vi /etc/chrony.conf

Uncomment the server directive and update the IP address against it, with that of your NTP server.

server 192.168.48.120

Restart chrony services with the following command.

# systemctl restart chronyd

Run the following command on NTP client system to view the NTP server sources that client is accessing.

# chronyc sources 

Run the following command on NTP server system to view the NTP clients that ping it for time.

# chronyc clients

That’s it. In this article, we have learnt how to install & configure NTP client & server using chrony package. You can use these steps on CentOS/Fedora/SUSE Linux as well.

Also read:

How to Enable & Disable Root Account in Ubuntu
How to Check RAM Size in Linux
How to Disable SELinux in CentOS
MySQL Row Number & Its Uses
How to Comment Multiple Lines in MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *