ntp 局域网时间同步 2020-03-17

这里以centos7 为例,其它系统差不多

主节点

vim /etc/ntp.conf

driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict ::1
restrict default nomodify
restrict default nomodify notrap 
#有网络连接时同步阿里云时间
server ntp4.aliyun.com
server 127.127.1.0
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
#添加此处。允许内网其他机器同步。
restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap

从节点

vim /etc/ntp.conf

ftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict ::1
restrict default nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
#这里是主节点的主机名或者ip
server master
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

重启服务

systemctl restart ntpd

验证

ntpstat

    synchronised to NTP server (119.28.206.193) at stratum 3
    time correct to within 25 ms
    polling server every 1024 s

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。