NTP不在CentOS中更新服务器时间

我编译NT胳膊我的NTP客户端不更新从任何服务器的时间我引用post“为什么ntpd没有更新我的服务器上的时间?(7)”但没有任何工程出来..这里是输出ntpq -pn

[Tue May 15 13:18:26 root@Unknown:bin]$./ntpq -pn remote refid st t when poll reach delay offset jitter ============================================================================== 125.62.193.121 .INIT. 16 u - 16 0 0.000 0.000 0.000 

我了解到refid不应该是“.INIT”,延迟,偏移,抖动值不应该是0

在看ntpd的日志

 [Tue May 15 13:19:08 root@Unknown:bin]$tail -f ntp.log 15 May 12:29:35 ntpd[18175]: proto: precision = 1000.000 usec 15 May 12:29:35 ntpd[18175]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 15 May 12:29:35 ntpd[18175]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123 15 May 12:29:35 ntpd[18175]: Listen normally on 1 lo 127.0.0.1 UDP 123 15 May 12:29:35 ntpd[18175]: Listen normally on 2 eth1 173.39.19.72 UDP 123 15 May 12:29:35 ntpd[18175]: peers refreshed 15 May 12:29:35 ntpd[18175]: Listening on routing socket on fd #19 for interface updates 

在一个侧面说明 – ntpupdate -u ntp.ubuntu.com工作,但ntpd不工作。 我的ntp.conf只包含一行

 server 91.189.94.4 minpoll 4 maxpoll 4 

上面的IP地址是ntp.ubuntu.com。


 [Fri May 18 15:12:26 root@Unknown:~]$ping pool.ntp.org PING pool.ntp.org (202.71.140.36): 56 data bytes 64 bytes from 202.71.140.36: seq=0 ttl=53 time=40.000 ms 64 bytes from 202.71.140.36: seq=1 ttl=53 time=39.000 ms 64 bytes from 202.71.140.36: seq=2 ttl=53 time=39.000 ms 64 bytes from 202.71.140.36: seq=3 ttl=53 time=39.000 ms 

平的作品,但服务器从来没有更新它的时间

你的ntpd认为远程系统是第16层(意味着它的可靠性最差)。 大多数ntp客户端不会与这样的系统同步。 我强烈build议使用pool.ntp.org 按照他们的指示描述 。

他们的例子ntp.conf文件:

 driftfile /var/lib/ntp/ntp.drift server 0.pool.ntp.org server 1.pool.ntp.org server 2.pool.ntp.org server 3.pool.ntp.org 

另外,除非你的系统由于一些疯狂的需求扭曲而不支持DNSparsing,否则你不应该在configuration文件中使用IP。

更新:
NTP池项目试图做一个半智能的猜测,它应该返回给你什么时间的服务器。 但是通常你应该通过在主机名中使用国家代码来指定你想要服务器的国家。 对于印度,这将是:

 server 0.in.pool.ntp.org server 1.in.pool.ntp.org server 2.in.pool.ntp.org server 3.in.pool.ntp.org 

同样的漂移,日志和其他选项仍然适用。

您的系统没有从您列出的服务器获取NTP响应,这就是“INIT”在“refid”列下的含义:它仍处于INITialization状态 – 发送数据包以获取INITial时间读数。

Ping可能会工作,但可能是防火墙阻止您的计算机与您试图访问的计算机之间的NTP(123 / udp)数据包。 或者可能是因为你的ntp.conf文件中有一个“限制”行,这个限制过于严格,所以即使数据包到达那里,它们也被忽略了。 请参阅此前的服务器故障问题:

问题与ntpd同步服务器时间

testingNTP数据包是否存在networking级问题的一种方法是以root用户身份运行“ntpdate {server}”,以查看是否会在本地设置时钟(注意:尝试此操作时,ntpd无法运行)。

如果“ntpdate”不起作用,这意味着某些东西阻塞了NTP数据包。 如果“ntpdate”起作用,但“ntpd”不是(作为问题中的当前情况),则意味着configuration中还有别的东西在破坏事物。

请记住,仅仅因为“ping”到另一个主机工作,并不意味着该主机上的服务工作。 这可能是你试图到达的服务是防火墙,或守护进程可能不在远程机器上运行。 Ping(和traceroute)只是在那里debuggingIP级别的连接:它们什么都不testing传输级(TCP,UDP)服务可用性/可达性。