NTP (Chrony) installation method (CentOS8)

Introduction

Network Time Protocol (NTP) is a network protocol for synchronizing time with a remote Internet time server.

Chrony is an implementation of NTP that replaces the old Ntpd used in earlier versions of the Enterprise Linux operating system.

I will explain the NTP (Chrony) installation of CentOS 8 and the following two setting methods.

①, configured as an NTP server When configured as an NTP server, the client PC or client server can synchronize the time of the NTP server. ②, configured as an NTP client When configured as an NTP client, the time on the configured NTP server can be synchronized.

Configured as an NTP server

### 1. Chrony installation Execute the following command to install. (It may already be installed)
# yum install -y chrony

2. Modify config file-permission to client

# vi /etc/chrony.conf

Execute the above command and add the following part of the Conf file. This time, set the access permission to synchronize the access time to the client PC of the local network from ** 192.168.0.0 ** to ** 192.168.0.254 **.

#Allow NTP client access from local netwok → Explanation comment
# allow 192.168.0.0/16 Example of setting →
allow 192.168.0.0/24 → Added here

Note. [** / 24 **] represents the number of ** 256 ** IPs from ** 192.168.0.0 ** to ** 192.168.0.255 ** of the subnet mask ** 255.255.255.0 **. ..

3. chrony restart

# systemctl restart chronyd

4. Set to automatically start chrony when the OS is restarted

# systemctl enable chronyd

5. Firewall settings

Add a firewall rule that allows NTP requests from client PCs.

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

6. Synchronize the time on the client PC

Add the time to the synchronization using the server set above as the NTP server on the client PC.

7. Check the client PC that is set to synchronize

You can check the list of clients accessing for synchronization by the time when the following command is executed.

# chronyc clients

Configure as NTP client

1. Chrony installation

# yum install -y chrony

2. Change config file-add server directive

  # vi /etc/chrony.conf

Comment out the existing server directive and add a new server directive for the NTP server.

# Use public servers from the pool.ntp.org project.→ Explanation comment out
# Please consider joining the pool (http://www.pool.ntp.org/join.html).→ Comment out about the confirmation site
# pool 2.centos.pool.ntp.org iburst → The current time is synchronized, but this is at the beginning#Add and comment out
server 192.168.0.21 Add the IP address of the NTP server that synchronizes the time → ‥ ‥ ‥ ‥ ‥ ‥ ‥ ‥ ‥ ‥ ‥ ‥ ‥

3. chrony restart

# systemctl restart chronyd

4. Confirmation of arrival at the NTP server

Check the time source to make sure the client is reaching the correct NTP server.

# chronyc sources 
Output:

210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? 192.168.0.21                  3   6     1    25  +2525us[+2525us] +/-   87ms

5. Synchronize manual time

By default, the NTP server is polled and synchronized every 64 seconds, but you can synchronize with the following command without waiting for the synchronization timing.

# chronyc makestep

that's all.

Recommended Posts

NTP (Chrony) installation method (CentOS8)
Installation of CentOS 8
PHP installation (CentOS 8)
CentOS 7 + ffmpeg installation
Python installation method Windows
Python 2.7 installation (yum) (CentOS 6.8)
Installation on CentOS8 VirtualBox
Python 3.5 installation (yum) (CentOS 6.8)
python (pyenv + pyenv-virtualenv) + CentOS7 installation
CentOS 8 installation procedure (latest version)
Docker Easy Installation Procedure (CentOS)
Apache installation fails on CentOS 8.2
JupyterLab3.0 Debugger Installation Method for Windows
Teamviewer for Linux installation procedure (CentOS)