centos linux ntp.conf 配置中 fudge 参数找不到
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了centos linux ntp.conf 配置中 fudge 参数找不到,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2922字,纯文字阅读大概需要5分钟。
内容图文
最近服务器被迫关机了一次,突然想把时间同步服务搞一搞 (内网
环境,无法连接互联网
)
为什么我要记录这个文章?
因为这玩意很简单,花了我几乎一天的时间.
总是报错,尝试修改配置,继续报错,再我几乎绝望,想吐槽 linux ntpd 垃圾的时候,它突然生效了,
只是因为加了一个配置interface listen 10.100.2.242
,也或许是因为刚好需要等待的时间到了.
我就不明白了,为什么网上都说要等几分钟才能生效呢? 我用ntpdate -d -v $IP
来同步,为什么给我
报错,我还不知道该怎么修改.
活该 linux 这么难用.
ntpd 服务器配置(10.100.2.242)
vim ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
#restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 10.100.2.0 mask 255.255.255.0 nomodify notrap
# 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 127.127.1.1 burst true prefer
#fudge 127.127.1.1 stratum 8
interface listen 10.100.2.242
#... 省略后面的了
关键的地方在于:
针对指定局域网网段是生效
restrict 10.100.2.0 mask 255.255.255.0 nomodify notrap
设置服务器自己作为单独的一个ntpd 服务器来提供服务
server 127.127.1.1 burst true prefer
再上述配置增加后,还不生效,神奇的,我找到了下面的几乎
无人提及配置,貌似生效了
interface listen 10.100.2.242
这个在man手册都没看到,怎么了?
fudge 127.127.1.1 stratum 0
fudge参数貌似不生效
ntpd --version
ntpd 4.2.6p5
根据 ntp.org 的记录,最新版本是4.2.8pX 系列, 这应该是版本问题了;
ntp 客户端配置 (10.100.2.243-249) 全部使用10.100.2.242
的时间配置
客户端就简单了,当测试ok,我就批量操作了:
yum install ntpd -y
sed -i 's/^server/#server/g' /etc/ntp.conf
line=`grep "#server" /etc/ntp.conf -n|tail -n 1|cut -d ':' -f 1`
if test -z "$line";then echo "not found server ";return;fi
sed -i -e "$line a server 10.100.2.242 prefer iburst" /etc/ntp.conf
systemctl enable ntpd||chkconfig --level 345 ntpd on
systemctl restart ntpd||service ntpd restart
ntpstat ; ntpq -p; ntpdate -d
date
ntpdate -v -d 10.100.2.242
date
终于生效了,开启各种ntpd服务,最好不要用crontab
来写ntpdate
的定时命令,ntpdate只适合手动运行.
后来又查了一下,原来windows的w32time
服务也是支持ntpd的, 既可以配置为ntpd server
,也可以作为ntp client
来
链接ntpd server
(不管是win还是linux的,通通支持),最关键的,配置很简单,使用很简单.
所以 linux 真好用.
REF: http://doc.ntp.org/
ntp.conf:很少有人提及的事
ntp的interface listen配置,绑定监听
内容总结
以上是互联网集市为您收集整理的centos linux ntp.conf 配置中 fudge 参数找不到全部内容,希望文章能够帮你解决centos linux ntp.conf 配置中 fudge 参数找不到所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。