Tuesday, February 16, 2021

NTP - setting up Network time protocol on RHEL8 with clients RHEL7 and windows

 NTP - Network time protocol

NTP was a widely used tool to synchronize the system time across the network.
Until RHEL7, it was available and it is not the primary choice. It has been replaced by chrony.

Chrony works as a server and client as well. It is used to synchronize the system clock with the NTP servers.
Also, it is used to synchronize the clock with GPS receiver (reference clock) or NTP servers.


Note: on Satellite (on space) time runs faster than earth, so, synchronization is very important...

How to configure ntp server and client on RHEL8 system.

Pre-requisites:
1. NTP server
2. NTP clients (at least 1 linux and 1 windows system)
3. Software packages.
4. Need root access

Tasks
1. Login to your RHEL8 system and check repo is set up
# dnf repolist    # yum repolist


2. Install chrony package
# dnf install chrony* -y

3. Edit the configuration file
# vi /etc/

go to line 22 and add entry to your network where NTP client can access the service.

allow 192.168.10.0/24    # your network

Now, Start the service. This service will maintain the chronyd service
# systemctl start chronyd (restart if its already running)
# systemctl enable chronyd
# systemctl status chronyd


4. Adding service to firewall so that other systems over the network can access the service
# firewall-cmd --permanent --add-service=ntp
Note: You can use either service or port. NTP port is UDP 123.

Reload the service with updated rules
# firewall-cmd --reload

5. Check how many clients are connecting to your ntp server
# chronyc clients

This gives you the list of clients systems but we have no output because we haven't
yet configured ntp client.


Configure NTP clients

1. Login to your system and configure yum. This system is RHEL7 (same on RHEL8 as well)
# dnf repolust
# yum install chrony -y or dnf install chrony* -y
or
go to software location and install the software
# cd /opt/OS_Image/Packages/
# rpm -ivh chrony

2. Start the chrony service
# systemctl start/enable/status chronyd

3. Configure the client by editing hte file /etc/chrony.conf
Go to the server section where you will see server 1, server2
These are the default servers. You have to change these to point
to your time server

# server <Your NTP server IP or name>
server 192.168.10.20

Restart the service
# systemctl restart chronyd


Verify if ntp set up is working
1. Login to NTP server and run
# chronyc sources

You see the IP address (hostname if dns working) of the server.

also check Stratum value.
if it is over 5, your NTP is not working properly or there will be a delayed on time sync..



Configure NTP on windows system
1. Login to your windows system
2. Press windows key on keyboard and type letter 'L'
   or Right click on Start and click on run
   or click on start -> type 'control pannel' and click on it
3. Click on Date and Time
4. Click on Internet Time tab
5. Click on Change setting
6. Clock on check box 'Synchronize with an internet time server
7. Specify the IP address of your linux time (NTP) server.
8. Click on update now and click ok.

Now, go back to your NTP server
- Check how many clients are connecting to your server
# chronyc clients

You will see list of client machines.
Check the IP of you client machines and should be good to go now...


If you like to change the time on windows (not to use ntp)
- go to control pannel -> data and time
- Internet time -> Change settings and uncheck the sync with internet time server
- Now, go to the time displayed at the bottom left corner and right click on it.
- Click on adjust data and time
- Click on time and change the date and time. you change some other time like a year ago..
- You see the time changed on bottom corner of your screen..

Now, go back to control pannel and sync with ntp server
- your time will be sync with ntpc servers

To reverify from time server, run
# chronyc sources


No comments:

Post a Comment

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...