在安装NTP服务器,客户端采用ntpdate遇到的问题
1、NTP服务器的安装,参考上篇博客
需要修改配置文件ntp.conf 。添加如下一行
restrict 172.22.26.111 mask 255.255.255.0 nomodify notrap
去掉或者添加下面注释
server 127.127.1.0
fudge 127.127.1.0 stratum 8
重启NTP服务器
service ntpd restart
查看端口是否存在
netstat -ulp | grep 123
需要查看防火墙是否关闭
如果iptables没有关闭,需要添加防火墙规则
iptables -A INPUT -s 172.17.14.0/24 -p udp --dport 6379 -j ACCEPT // 172.17.14网段可以访问ntp服务器123端口
iptables -A INPUT -p udp --dport 123 -j REJECT // 其他访问123端口拒绝
service iptables save
service iptables restart
客户端通过定时任务与ntp服务器同步
crontab -e
*/5 * * * * /usr/sbin/ntpdate 172.17.14.111 && hwclock --systohc
通过命令:ntpdate 172.17.14.111 查看同步信息情况
常遇到的问题
# ntpdate -d 192.168.70.11
4 Apr 05:26:56 ntpdate[2057]: ntpdate 4.2.4p8@1.1612-o Fri Feb 22 11:23:28 UTC 2013 (1)
Looking for host 192.168.70.11 and service ntp
host found : server.neo.com
transmit(192.168.70.11)
receive(192.168.70.11)
transmit(192.168.70.11)
receive(192.168.70.11)
transmit(192.168.70.11)
receive(192.168.70.11)
transmit(192.168.70.11)
receive(192.168.70.11)
transmit(192.168.70.11)
server 192.168.70.11, port 123
stratum 16, precision -24, leap 00, trust 000
refid [192.168.70.11], delay 0.02582, dispersion 0.00000
transmitted 4, in filter 4
reference time: d758e781.49a1617b Sat, Jun 28 2014 15:04:33.287
originate timestamp: d758e7ab.8db9fc66 Sat, Jun 28 2014 15:05:15.553
transmit timestamp: d6e850a0.6b3af2bc Fri, Apr 4 2014 5:26:56.418
filter delay: 0.02707 0.02585 0.02582 0.02582
0.00000 0.00000 0.00000 0.00000
filter offset: 7378699. 7378699. 7378699. 7378699.
0.000000 0.000000 0.000000 0.000000
delay 0.02582, dispersion 0.00000
offset 7378699.134602
4 Apr 05:26:56 ntpdate[2057]: step time server 192.168.70.11 offset 7378699.134602 sec
查看配置文件
server 127.127.1.0
fudge 127.127.1.0 stratum 8
是否添加