Note Centos uses chronyd as default ntp to recieve time this means ntp will not start up on boot due to chronyd allready using port 123. In order to fix this disable chronyd like this.
systemctl disable chronyd
Note ntp is not available in CentOS 8 and you will have to use chronyd.
Next install ntp.
yum install ntp
systemctl start ntpd systemctl enable ntpd
Next adjust the configuration to suit your needs.
vi /etc/ntp.conf
Find the following line.
driftfile /var/lib/ntp/drift
And add the following below so it looks like this.
driftfile /var/lib/ntp/drift logfile /var/log/ntp.log
Next we are goint to tight global access to the server. Find this line.
restrict default nomodify notrap nopeer
Append "noquery kod limited" at the end so that it looks like this.
restrict default nomodify notrap nopeer noquery kod limited
Next we are goint to adjust which hosts are allowed to perform queries. Find the following line.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
And add the following lines below.
Note these lines are just examples adjust to your own need.
restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer limited restrict 172.16.0.0 mask 255.240.0.0 nomodify notrap nopeer limited restrict 172.31.0.0 mask 255.255.254.0 nomodify notrap nopeer limited
Next replace the standard ntp server pools listed below
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
With whatever you prefer like the example below.
server 0.dk.pool.ntp.org server 1.dk.pool.ntp.org server 2.dk.pool.ntp.org server 3.dk.pool.ntp.org
and finally restart the ntp server.
systemctl restart ntpd
Check if everything is working.
ntpq -p
Test if firewall allows remote sync to timeservers
ntpdate -qu 0.dk.pool.ntp.org