背景:
linux系统时间不同步,手动执行
ntpdate time2.aliyun.com
报错
no server suitable for synchromization found
登陆系统,先看看时间
1,查看系统时间
date
hwclock --show 查看硬件时间
2,查看ntp.conf
3,手动同步,看看现场(多试几个~)
4,使用调试模式看下
ntpdate -d 10.143.33.50
返回如下:
7 Mar 09:46:51 ntpdate[24930]: ntpdate 4.2.2p1@1.1570-o Sat Dec 20 02:52:11 UTC 2014 (1)
Looking for host 10.143.33.50 and service ntp
host found : 10.143.33.50
transmit(10.143.33.50)
transmit(10.143.33.50)
transmit(10.143.33.50)
transmit(10.143.33.50)
transmit(10.143.33.50)
10.143.33.50: Server dropped: no data
server 10.143.33.50, port 123
stratum 0, precision 0, leap 00, trust 000
refid [10.143.33.50], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time: 00000000.00000000 Thu, Feb 7 2036 14:28:16.000
originate timestamp: 00000000.00000000 Thu, Feb 7 2036 14:28:16.000
transmit timestamp: dc688f8e.b4e8c8ab Tue, Mar 7 2017 9:46:54.706
filter delay: 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000
filter offset: 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000
delay 0.00000, dispersion 64.00000
offset 0.000000
7 Mar 09:46:55 ntpdate[24930]: no server suitable for synchronization found
5,根据debug到的报错,有2个原因可能导致该问题
5.1,检查ntp的版本,如果你使用的是ntp4.2(包括4.2)之后的版本,在restrict的定义中使用了notrust的话,会导致以上错误。
使用以下命令检查ntp的版本:
ntpq -c version
下面是来自ntp官方网站的说明:
The behavior of notrust changed between versions 4.1 and 4.2.
In 4.1 (and earlier) notrust meant "Don't trust this host/subnet for time".
In 4.2 (and later) notrust means "Ignore all NTP packets that are not cryptographically authenticated." This forces remote time servers to authenticate themselves to your (client) ntpd
解决:
把notrust去掉。
5.2,检查ecs的防火墙。可能是防火墙屏蔽了udp 123端口。(ecs的话还要注意安全组)
可以用命令停止防火墙测试
service iptables stop
本例原因是iptables规则设置有问题导致
进阶版-->ipv6引起的对时超时