How to configure NTP in RHEL8 or CentOS 8 by chronyd.

Network Time Protocol is used in systems to get the clock synced between them. All systems will sync their clock with NTP server is they are configured to do so. In RHEL8 or CentOS 8 it is achieved through “chronyd”. The “chronyd” daemon can be managed by the command “chronyc”.

Below steps involve in configuring NTP through chronyd in linux systems.

·        Install the necessary packages.
·        Configure chrony service to sync with NTP server.
·        Set NTP synchronization.
·        Enable necessary firewall rules.
·        Enable and start chronyd service.

Installation of chrony on RHEL8 or CentOS8.

The below command helps to install chronyd in RHEL/CentOS 8.

[root@system1 ~]# yum install chrony -y

Chrony (NTP) server configuration

The main configuration file for “chronyd” is /etc/chrony.conf.

[root@system1 ~]# vim /etc/chrony.conf

Below the minimum details to be set in the chrony.conf file.

·        pool iburst  # The name of the pool where NTP server to which the time to be synched resides. Comment out this line and add the following servers like below.

#pool iburst
server iburst
server iburst
server iburst
server iburst

            You may find out the nearest NTP servers from here.

·        driftfile /var/lib/chrony/drift - Name of the file where it can find and store the clock drift, also known as frequency error, of the system clock.
·        makestep 1.0 3 - Allow the system clock to be stepped in the first three updates if its offset is larger than 1 second.
·        rtcsync - Enable kernel synchronization of the real-time clock (RTC).
·        allow - Allow NTP client access from local network.
·        keyfile /etc/chrony.keys - Specify file containing keys for NTP authentication.
·        leapsectz right/UTC - Get TAI-UTC offset and leap seconds from the system tz database.
·        logdir /var/log/chrony - Specify directory for log files.

Set NTP synchronization

[root@system1 ~]# timedatectl set-ntp true

Enable firewall rules

[root@system1 ~]# firewall-cmd --add-service=ntp –permanent
[root@system1 ~]# firewall-cmd –reload

Enable and start “chronyd” service.

[root@system1 ~]# systemctl enable chronyd

[root@system1 ~]# systemctl status chronyd

Check the functionality of chronyd by “chronyc” command

[root@system1 ~]# chronyc sources

“*” indicates that the server is in sync with one of the external NTP server.

Now this server will work as a NTP server in your environment and other servers in your premise can connect with this server for time synchronization. Let's see how to configure your client servers to connect with this server now.

Configure NTP on the client servers of RHEL 8 or CentOS 8

The NTP client configuration follows the same steps as your NTP server described above. The only difference is to give the server name of your NTP server in the configuration file to sync with.

Again, the steps are:
1.     Install chrony software.

[root@client1 ~]# yum install chrony -y

2.     Configure to sync with your NTP server.

[root@client1 ~]# grep server /etc/chrony.conf |grep -v "^#"
server iburst
[root@client1 ~]#

3.     Set NTP synchronization.

[root@client1 ~]# timedatectl set-ntp true

4.     Enable firewall rules.

root@client1 ~]# firewall-cmd --add-service=ntp –permanent
root@client1 ~]# firewall-cmd –reload

5.     Enable and start the service.

root@client1 ~]# systemctl enable chronyd
root@client1 ~]# systemctl start chronyd

6.     Check the functionality

[root@system1 ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
^*     1   7   377   109   -234us[ -277us] +/-   15ms
[root@system1 ~]#

Enjoy :)

More readings:

  1. Apache Configuration - RHEL 7 & CentOS 7
  2. Primary DNS Configuration - RHEL6 & CentOS 6
  3. Apache with Open SSL (HTTPS) - RHEL7 & CentOS 7
  4. Host Name Configuration - RHEL 8, CentOS 8, RHEL 7 & CentOS 7


Post a Comment

Popular posts from this blog

AIX Firefox Installation

Upgrade curl 7.29 to 7.69 in CentOS 7 or RedHat 7

How to increase swap size on CentOS 8 / RHEL 8

YUM configuration in AIX.

How to enable VNC server (get GUI remotely) in CentOS 7, RHEL 7, CentOS 8 and RHEL 8 servers.

AIX Commands

Remote X11 forwarding for AIX in command line.

BareMetal restoration of Linux (RedHat or CentOS) by ReaR.

How to change or configure hostname/Server Name in RHEL 7, CentOS 7, RHEL 8 or CentOS 8 systems.