Author: Madhan Gopalakrishnan | Published on : 10-02-2025

Network Time Protocol (NTP) is crucial for keeping system time synchronized across Linux servers and Linux clients. This guide covers the installation, configuration and client-server setup for CentOS/RHEL Linux 7, 8, and 9 with details. š
š Step 1: Install NTP or Chrony
š CentOS/RHEL 7 uses ntpd
(deprecated in RHEL 8+).
š CentOS/RHEL 8 & 9 use chronyd
(default and recommended).
For CentOS/RHEL 7 (ntpd)
yum install -y ntp
The installed package includes:
ntpd
: The NTP daemon responsible for synchronizing system time.ntpdate
: A tool to manually sync time with an NTP server.ntpstat
: A utility to check synchronization status.
For CentOS/RHEL 8 and 9 (Chrony)
yum install -y chrony
The installed package includes:
chronyd
: The daemon for time synchronization.chronyc
: A command-line tool to query and modify Chrony settings.chrony.conf
: Configuration file for defining NTP servers and rules.
š Step 2: Enable and Start the NTP Service
For CentOS/RHEL 7 (ntpd)
systemctl enable ntpd --now
For CentOS/RHEL 8 and 9 (Chrony)
systemctl enable chronyd --now
š§ Step 3: Configure NTP Servers
For CentOS/RHEL 7 (ntpd)
Edit the configuration file:
nano /etc/ntp.conf
Replace or add the following servers:
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
Restart the service:
systemctl restart ntpd
For CentOS/RHEL 8 and 9 (Chrony)
Edit the Chrony configuration:
nano /etc/chrony.conf
Add or modify the following lines:
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
Restart the service:
systemctl restart chronyd
ā Step 4: Verify Synchronization
Check if NTP is syncing correctly.
For CentOS/RHEL 7 (ntpd)
ntpq -p
For CentOS/RHEL 8 and 9 (Chrony)
chronyc sources -v
Check system time:
timedatectl status
š„ Step 5: Allow NTP Through Firewall
firewall-cmd --add-service=ntp --permanent
firewall-cmd --reload
š¢ NTP Server and Client Configuration
š” Server Configuration (NTP Master)
Edit the NTP configuration file.
For CentOS/RHEL 7 (ntpd)
nano /etc/ntp.conf
Uncomment or add:
restrict default nomodify notrap noquery
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
broadcast 192.168.1.255
Restart the service:
systemctl restart ntpd
For CentOS/RHEL 8 and 9 (Chrony)
nano /etc/chrony.conf
Add:
allow 192.168.1.0/24
local stratum 10
Restart the service:
systemctl restart chronyd
š„ļø Client Configuration
For CentOS/RHEL 7 (ntpd)
Edit /etc/ntp.conf
:
server 192.168.1.1 prefer iburst
Restart the service:
systemctl restart ntpd
For CentOS/RHEL 8 and 9 (Chrony)
Edit /etc/chrony.conf
:
server 192.168.1.1 iburst
Restart the service:
systemctl restart chronyd
š Check Time Synchronization
For CentOS/RHEL 7:
ntpq -p
For CentOS/RHEL 8 and 9:
chronyc tracking
š Congratulations! Your NTP server and clients are now synchronized! š