环境:服务器CentOS,测试客户端Kali
1) 安装软件 yum instal ntpd –y
![](https://img.haomeiwen.com/i10392259/1fdea32ef0c6b8bd.png)
2) 启动ntpd查看状态
![](https://img.haomeiwen.com/i10392259/d8dd6277f0e8d271.png)
3) 配置CentOS为本地ntp服务器(最上游),对同网络客户进行时间同步
![](https://img.haomeiwen.com/i10392259/3cfd3b6b8867e4b7.png)
![](https://img.haomeiwen.com/i10392259/401c9506d11b233e.png)
![](https://img.haomeiwen.com/i10392259/662c57cef50725c7.png)
所有配置文件
driftfile /var/lib/ntp/drift
#1
#允许与我们的时间源同步时间,但是不允许源查询或修改这个系统上的服务。
#restrict default nomodify notrap nopeer noquery
#restrict -6 default nomodify notrap nopeer noquery
#restrict 140.143.246.125
restrict 127.0.0.1
#restrict ::1
restrict 192.168.1.0 mask 255.255.255.0 nomodify
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#2
#配置上游服务器同步时间
#server 140.143.246.125
#3
#设置本地主机作为服务器 127.127.1.0 代表本机 stratum 0 表示1级primary reference
#想配置本地时间服务器server 127.127.1.0 必须这样写
server 127.127.1.0 prefer fudge 127.127.1.0 stratum 0
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
4) 配置客户端连接上游本地ntp服务器(CentOS)
![](https://img.haomeiwen.com/i10392259/33fbff27fd58f21f.png)
![](https://img.haomeiwen.com/i10392259/ef1562f59969b56c.png)
5)时间同步测试
修改服务器时间让客户机进行同步
![](https://img.haomeiwen.com/i10392259/6816dd7cb3c71fa1.png)
客户端出现时间差距:等待时间同步进行查看
![](https://img.haomeiwen.com/i10392259/227120d87132eae8.png)
时间同步完成
![](https://img.haomeiwen.com/i10392259/fed7e425eb5b40be.png)
网友评论