Configure NTP Server on Centos 7

The Network Time Protocol (NTP) is used to synchronize the time of a computer client or server to another server. To install ntp on centos 7 using commands below:

[root@tekbloq ~]# yum -y install ntp

To configure ntp server you needs to open configuration file /etc/ntp.conf.

# Hosts on local network are less restricted.
restrict 172.16.171.0 mask 255.255.255.0 nomodify notrap

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

# add your ntp server here
server 0.az.pool.ntp.org

#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

If you have firewall enabled You may add ntp to firewall allow list and restart the firewall service.

[root@tekbloq ~]# firewall-cmd –add-service=ntp –permanent
[root@tekbloq ~]# firewall-cmd –reload

You can test ntp service ntpq -p commands.

To start, stop, restart and to look at ntp service status You can run commands as follow:

[root@tekbloq ~]# systemctl status ntpd
ntpd.service – Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
Active: active (running) since Mon 2019-10-21 07:01:13 EDT; 1 day 1h ago
Process: 592 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 603 (ntpd)
CGroup: /system.slice/ntpd.service
ââ603 /usr/sbin/ntpd -u ntp:ntp -g
ââ604 /usr/sbin/ntpd -u ntp:ntp -g

[root@tekbloq ~]# systemctl stop ntpd
[root@tekbloq ~]# systemctl start ntpd
[root@tekbloq ~]# systemctl restart ntpd

If You have any question about this or another topic Please feel free to email us. You can also ask to create specific articles which you want to see on our blog.

Subscribe to Us to get all interesting articles.

GOOD LUCK!!!

Add Comment