随笔-内网ntps服务器搭建

1、server端修改配置文件

[root@localhost ~]# vim /etc/ntp.conf
# 允许内网的其他机器同步:
restrict 192.168.78.0 mask 255.255.255.0 nomodify notrap

# 外部时间服务器不可用时,以本地时间作为时间服务
server 127.127.1.0  
fudge  127.127.1.0   stratum  5

测试:client端:ntpdate -u 192.168.99.85

2、client端使用ntpd,仍编辑/etc/ntp.conf

# 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
# server 3.centos.pool.ntp.org iburst
server 192.168.99.85
# 允许上层时间服务器主动修改本机时间
restrict 192.168.99.85 nomodify notrap noquery

3、重启ntpd

# 查看服务器是否添加成功:
ntpq -p

# 手动同步时间:
ntpdate -u 192.168.99.85

参考:https://www.jianshu.com/p/4842f079e111

posted @ 2024-12-28 18:29  LiYanbin  阅读(36)  评论(0)    收藏  举报