Rob's web

NTP server

Chrony is an implementation of the Network Time Protocol (NTP). You can use Chrony:

Checking status

# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since do 2020-11-12 14:44:58 CET; 1h 4min ago
....

If don't see the above then install chrony.

Installation

# yum install chrony

Configuration

The configuration is put in the file ntp.conf.

ntp.conf

Open ntp.conf.

Edit it that it looks like below.

Change the server *.centos.pool.ntp.org for your area. In my case I use nl (0.nl.pool.ntp.org). Use min 4 servers and maximal 7.

[root@server4 etc]# cat chrony.conf
# These servers were defined in the installation:
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

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking

Starting cronyd

# systemctl start chronyd
# systemctl enable chronyd

Checking if chrony is synchronized

To check if chrony is synchronized, make use of the tracking, sources, and sourcestats commands.

Checking chrony tracking

To check chrony tracking, issue the following command:

# chronyc tracking

Checking chrony sources

The sources command displays information about the current time sources that chronyd is accessing.

The optional argument -v can be specified, meaning verbose. In this case, extra caption lines are shown as a reminder of the meanings of the columns.

# chronyc sources

Checking chrony source statistics

The sourcestats command displays information about the drift rate and offset estimation process for each of the sources currently being examined by chronyd.

The optional argument -v can be specified, meaning verbose. In this case, extra caption lines are shown as a reminder of the meanings of the columns.

# chronyc sourcestats

Firewall

Add to the firewall rules.

# firewall-cmd --permanent --zone=public --add-port=123/udp

For global acces forward port 123 udp in your modem/router to your NTP-server.

Links