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 2.centos.pool.ntp.org 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 2.rhel.pool.ntp.org iburst
server 0.in.pool.ntp.org iburst
server 1.in.pool.ntp.org iburst
server 2.in.pool.ntp.org iburst
server 3.in.pool.ntp.org 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 192.168.1.0/24 - 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 server1.example.com 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
===============================================================================
^* server1.example.com     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

Comments

Popular posts from this blog

AIX Firefox Installation

AIX Commands

How to increase swap size on CentOS 8 / RHEL 8

System Administration

How to manage Linux systems through web browser (cockpit for Linux): CentOS 7, CentOS 8, RHEL 7, RHEL 8, Fedora, Ubuntu and Debian systems.

How to find big files in Linux, Unix, AIX

Remote X11 forwarding for AIX in command line.

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

How to change Time Zone in CentOS 8, RHEL 8 and Ubuntu systems