-->

Configure NTP Server And Client CentOS 7



Configure NTP Server

install NTPd and Configure NTP server for time adjustment.
Install NTPd.
[root@dlp ~]# yum -y install ntp
[root@dlp ~]# vi /etc/ntp.conf

# line 18: add the network range you allow to receive requests
restrict 10.0.0.0 mask 255.255.255.0 nomodify notrap

# change servers for synchronization
#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
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst

[root@dlp ~]# systemctl start ntpd
[root@dlp ~]# systemctl enable ntpd

If Firewalld is running, allow NTP service. NTP uses 123/UDP.
[root@dlp ~]# firewall-cmd --add-service=ntp --permanent
success
[root@dlp ~]# firewall-cmd --reload
success

Verify it works normally like follows.

[root@dlp ~]# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp1.jst.mfeed. 172.29.1.100     2 u   29   64    1   18.826   -0.126   0.000
+ntp2.jst.mfeed. 172.29.2.50      2 u   28   64    1   21.592    0.018   0.000
*ntp3.jst.mfeed. 133.243.236.18   2 u   28   64    1   22.666   -1.033   0.000
Install Chrony and Configure NTP server for time adjustment.
Install Chrony.
[root@dlp ~]# yum -y install chrony
[root@dlp ~]# vi /etc/chrony.conf

# line 3: change servers for synchronization
#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
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst

# line 25: add the network range you allow to receive requests
allow 10.0.0.0/24

[root@dlp ~]# systemctl start chronyd
[root@dlp ~]# systemctl enable chronyd

If Firewalld is running, allow NTP service. NTP uses 123/UDP.
[root@dlp ~]# firewall-cmd --add-service=ntp --permanent
success
[root@dlp ~]# firewall-cmd --reload
success

Verify it works normally like follows.
[root@dlp ~]# chronyc sources
210 Number of sources = 3
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ ntp1.jst.mfeed.ad.jp          2   6    17     8  -1028us[-1261us] +/-   14ms
^* ntp2.jst.mfeed.ad.jp          2   6    17     8  -1241us[-1474us] +/-   15ms
^? ntp3.jst.mfeed.ad.jp          0   6     0   10y     +0ns[   +0ns] +/-    0ns
NTP Client
    
The settings of NTP Client on CentOS are mostly the same with Server's settings, so refer to NTPd Settings or Chrony Settings. For different settings from Server's one, Clients don't need to receive time synchronization requests from other computers, so it does not need to set access permission.

If you don't use NTP service daemon but use a command to sync time at once, use ntpdate like follows.
[root@dlp ~]# yum -y install ntpdate

[root@dlp ~]# ntpdate ntp1.jst.mfeed.ad.jp
24 Jan 11:35:15 ntpdate[5740]: adjust time server xxx.xxx.xxx.xxx offset 0.004626 sec

[root@dlp ~]# systemctl enable ntpdate

Berlangganan update artikel terbaru via email:

0 Response to "Configure NTP Server And Client CentOS 7"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel