ntpdate -d似乎成功,但是ntpdate没有返回适合的服务器


14

我有一个未运行ntpd的系统,在该系统上尝试使用ntpdate更新时钟。该系统是一个似乎基于CentOS 6的设备。

当我跑步时ntpdate 0.pool.ntp.org,我得到:

8 Sep 17:52:05 ntpdate[7445]: no server suitable for synchronization found

但是,当我这样做时ntpdate -d 0.pool.ntp.org,我得到:

8 Sep 17:55:14 ntpdate[9499]: ntpdate 4.2.2p1@1.1570-o Fri Nov 18 13:21:21 UTC 2011 (1)
Looking for host 0.pool.ntp.org and service ntp
host found : 4.53.160.75
transmit(4.53.160.75)
receive(4.53.160.75)
transmit(4.53.160.75)
receive(4.53.160.75)
transmit(4.53.160.75)
receive(4.53.160.75)
transmit(4.53.160.75)
receive(4.53.160.75)
transmit(4.53.160.75)
transmit(64.16.214.60)
receive(64.16.214.60)
transmit(64.16.214.60)
receive(64.16.214.60)
transmit(64.16.214.60)
receive(64.16.214.60)
transmit(64.16.214.60)
receive(64.16.214.60)
transmit(64.16.214.60)
transmit(54.236.224.171)
receive(54.236.224.171)
transmit(54.236.224.171)
receive(54.236.224.171)
transmit(54.236.224.171)
receive(54.236.224.171)
transmit(54.236.224.171)
receive(54.236.224.171)
transmit(54.236.224.171)
transmit(50.22.155.163)
receive(50.22.155.163)
transmit(50.22.155.163)
receive(50.22.155.163)
transmit(50.22.155.163)
receive(50.22.155.163)
transmit(50.22.155.163)
receive(50.22.155.163)
transmit(50.22.155.163)
server 4.53.160.75, port 123
stratum 2, precision -23, leap 00, trust 000
refid [4.53.160.75], delay 0.03160, dispersion 0.00005
transmitted 4, in filter 4
reference time:    d7b867d0.f9841075  Mon, Sep  8 2014 17:37:20.974
originate timestamp: d7b86c03.b6a49dae  Mon, Sep  8 2014 17:55:15.713
transmit timestamp:  d7b86c02.7e12a51e  Mon, Sep  8 2014 17:55:14.492
filter delay:  0.03189  0.03188  0.03172  0.03160
         0.00000  0.00000  0.00000  0.00000
filter offset: 1.218061 1.217856 1.218023 1.217968
         0.000000 0.000000 0.000000 0.000000
delay 0.03160, dispersion 0.00005
offset 1.217968

server 64.16.214.60, port 123
stratum 2, precision -23, leap 00, trust 000
refid [64.16.214.60], delay 0.04886, dispersion 0.00006
transmitted 4, in filter 4
reference time:    d7b86425.55948a73  Mon, Sep  8 2014 17:21:41.334
originate timestamp: d7b86c03.f7d91219  Mon, Sep  8 2014 17:55:15.968
transmit timestamp:  d7b86c02.bed42c3c  Mon, Sep  8 2014 17:55:14.745
filter delay:  0.04919  0.04892  0.04912  0.04886
         0.00000  0.00000  0.00000  0.00000
filter offset: 1.210967 1.210879 1.210967 1.210836
         0.000000 0.000000 0.000000 0.000000
delay 0.04886, dispersion 0.00006
offset 1.210836

server 54.236.224.171, port 123
stratum 3, precision -20, leap 00, trust 000
refid [54.236.224.171], delay 0.04878, dispersion 0.00011
transmitted 4, in filter 4
reference time:    d7b864eb.b06fee7d  Mon, Sep  8 2014 17:24:59.689
originate timestamp: d7b86c04.2b9d2547  Mon, Sep  8 2014 17:55:16.170
transmit timestamp:  d7b86c02.f1e80bed  Mon, Sep  8 2014 17:55:14.944
filter delay:  0.04977  0.04950  0.04878  0.04887
         0.00000  0.00000  0.00000  0.00000
filter offset: 1.214091 1.214069 1.213755 1.213750
         0.000000 0.000000 0.000000 0.000000
delay 0.04878, dispersion 0.00011
offset 1.213755

server 50.22.155.163, port 123
stratum 2, precision -23, leap 00, trust 000
refid [50.22.155.163], delay 0.07384, dispersion 0.00005
transmitted 4, in filter 4
reference time:    d7b869c9.2b3f3d0b  Mon, Sep  8 2014 17:45:45.168
originate timestamp: d7b86c04.75472e97  Mon, Sep  8 2014 17:55:16.458
transmit timestamp:  d7b86c03.384a83b1  Mon, Sep  8 2014 17:55:15.219
filter delay:  0.07408  0.07414  0.07384  0.07387
         0.00000  0.00000  0.00000  0.00000
filter offset: 1.214115 1.214122 1.214012 1.214069
         0.000000 0.000000 0.000000 0.000000
delay 0.07384, dispersion 0.00005
offset 1.214012

 8 Sep 17:55:15 ntpdate[9499]: step time server 4.53.160.75 offset 1.217968 sec

根据我以前的搜索,此结果(带有各种receive()行和偏移量)表明它正在与远程NTP服务器正确通信(未被防火墙阻止)。那么,为什么我运行时钟时不更新时钟?

Answers:


16

尝试将其运行为:

ntpdate -u 0.pool.ntp.org

-u提供配置ntpdate以使用非特权端口,当你使用它总是这样-d的选择。

因此,它可以使用-u-d但不能同时使用),我会仔细检查您的防火墙。

从手册页:

-u指示ntpdate将非特权端口用于传出数据包。当在防火墙后面阻止到特权端口的传入流量,并且您想与防火墙之外的主机同步时,此功能非常有用。请注意,-d选项始终使用非特权端口。


1
做到了。我猜想我在该服务器之外的地方有一个限制性更强的防火墙,由于-d起作用,所以我不见了。谢谢!
csyria 2014年

2

在iptables中添加以下规则:

iptables -t nat -A POSTROUTING -p udp --sport 123 -j MASQUERADE --to-ports 1025-65535

2
你好诺伯托。这可能很好地解决了问题,但是如果您可以编辑答案以说明这样做的原因,则将非常有帮助。
roaima

1
对于不赞成投票的人:不赞成投票的理由是有礼貌的,并且很有可能会有所帮助。IMO没有任何内在的错误,一点点解释都无法解决。
roaima
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.