Centos上配置NTP server

安装NTP服务

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

修改配置文件

[root@xuxing ~]# cat  /etc/ntp.conf | grep -v ^# | grep -v ^$
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict ::1

restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap   <<<<< 选择ntp server 服务的client 范围
server 1.ntp.esl.cisco.com iburst                  <<<<< server 去网站https://www.pool.ntp.org/zone/asia选取对应地区server
server 2.ntp.esl.cisco.com iburst
server 3.ntp.esl.cisco.com iburst
                                                              
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
[root@xuxing ~]# 

添加防火墙规则并重启

[root@xuxing ~]# firewall-cmd --add-service=ntp --permanent
[root@xuxing ~]# firewall-cmd --reload
[root@xuxing ~]# systemctl start ntpd
[root@xuxing ~]# systemctl enable ntpd
[root@xuxing ~]# systemctl status ntpd

检查server状态

[root@xuxing ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*bgl11-row1-dc-n .GNSS.           1 u   59   64   37  128.524    0.521   0.301
+mtv5-ai27-dcm10 .GNSS.           1 u   49   64   77  191.412    2.389   0.507
+mtv5-ai27-dcm10 .GNSS.           1 u   21   64   77  192.614    1.762   0.420
[root@xuxing ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*bgl11-row1-dc-n .GNSS.           1 u   66   64   37  128.524    0.521   0.301
+mtv5-ai27-dcm10 .GNSS.           1 u   56   64   77  191.412    2.389   0.507
+mtv5-ai27-dcm10 .GNSS.           1 u   28   64   77  192.614    1.762   0.420
[root@xuxing ~]# 
[root@xuxing ~]# 
[root@xuxing ~]# date -R
Mon, 30 Mar 2020 12:20:21 -0400

<<<<< 一些参数解释解释
when   Time since last NTP packet was received from peer, in milliseconds.
poll   Polling interval, in seconds.
reach  Peer reachability (bit string, in octal).
delay  Round-trip delay to peer, in milliseconds.
offset Relative time difference between a peer clock and a local clock, in milliseconds.
           

No comments

Comments feed for this article

Reply

Your email address will not be published. Required fields are marked *