ntpdate: 没有适合同步的服务器

分享于 

9分钟阅读

ubuntu

  繁體

问题

我尝试了几个不同的NTP服务器,但总是得到以下错误消息:


$ sudo ntpdate ntp.ubuntu.com


4 Mar 12:27:35 ntpdate[1258]: no server suitable for synchronization found


$ sudo ntpdate pool.ntp.org


4 Mar 12:27:50 ntpdate[1267]: no server suitable for synchronization found


$ sudo ntpdate de.pool.ntp.org


4 Mar 12:28:01 ntpdate[1273]: no server suitable for synchronization found


$ sudo ntpdate us.pool.ntp.org


4 Mar 12:28:12 ntpdate[1276]: no server suitable for synchronization found



端口123可能在工作地点的电脑/网络被阻止。


$ sudo nmap -p123 -sU -P0 localhost


...


PORT STATE SERVICE


123/udp closed ntp 


...


$ sudo ufw allow 123/udp


Rules updated


Rules updated (v6)


$ sudo nmap -p123 -sU -P0 localhost


...


PORT STATE SERVICE


123/udp open ntp


...



但是仍然:


$ sudo ntpdate ntp.ubuntu.com


4 Mar 13:06:16 ntpdate[4361]: no server suitable for synchronization found



即使使用-u选项,它也告诉ntpdate使用一个非权限端口来同步(而不是端口123 ),这肯定不会阻止工作


$ sudo ntpdate -u ntp.ubuntu.com


4 Mar 13:06:28 ntpdate[4427]: no server suitable for synchronization found



看看更多的调试信息:


$ sudo ntpdate -dv ntp.ubuntu.com


 4 Mar 13:12:24 ntpdate[4523]: ntpdate 4.2.6p5@1.2349-o Wed Oct 9 19:08:07 UTC 2013 (1)


Looking for host ntp.ubuntu.com and service ntp


host found : golem.canonical.com


transmit(91.189.89.199)


transmit(91.189.94.4)


transmit(91.189.89.199)


transmit(91.189.94.4)


transmit(91.189.89.199)


transmit(91.189.94.4)


transmit(91.189.89.199)


transmit(91.189.94.4)


transmit(91.189.89.199)


transmit(91.189.94.4)


91.189.89.199: Server dropped: no data


91.189.94.4: Server dropped: no data


server 91.189.89.199, port 123


stratum 0, precision 0, leap 00, trust 000


refid [91.189.89.199], delay 0.00000, dispersion 64.00000


transmitted 4, in filter 4


reference time: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000


originate timestamp: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000


transmit timestamp: d6c041ae.e6166441 Tue, Mar 4 2014 13:12:30.898


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



server 91.189.94.4, port 123


stratum 0, precision 0, leap 00, trust 000


refid [91.189.94.4], delay 0.00000, dispersion 64.00000


transmitted 4, in filter 4


reference time: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000


originate timestamp: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000


transmit timestamp: d6c041af.1948fc50 Tue, Mar 4 2014 13:12:31.098


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



 4 Mar 13:12:33 ntpdate[4523]: no server suitable for synchronization found



Pfeeewww,这是一个很长的,抱歉,

sudo ntpdate -u HOSTNAMEno server suitable for synchronization foundthe NTP socket is in use, exiting

同样:


$ timedatectl status


 Local time: Wed 2014-03-05 13:11:54 CET


 Universal time: Wed 2014-03-05 12:11:54 UTC


 Timezone: Europe/Berlin (CET, +0100)


 NTP enabled: yes


NTP synchronized: yes


 RTC in local TZ: no


 DST active: no


 Last DST change: DST ended at


 Sun 2013-10-27 02:59:59 CEST


 Sun 2013-10-27 02:00:00 CET


 Next DST change: DST begins (the clock jumps one hour forward) at


 Sun 2014-03-30 01:59:59 CET


 Sun 2014-03-30 03:00:00 CEST



现在UTC时间是11:11,而不是12:11

和:


$ sudo hwclock --show


Wed 05 Mar 2014 01:11:56 PM CET -0.625627 seconds




答案1


transmit(91.189.94.4)


transmit(91.189.89.199)


transmit(91.189.94.4)


transmit(91.189.89.199)



联系你的ISP,询问他们是否阻止外部ntp请求,如果他们有本地服务器,你可以使用时间同步。


答案2


sudo date -s"$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"




答案3

首先安装ntpdate (显然你已经完成了)


sudo apt-get install ntpdate



接下来,你需要用服务器配置ntp,如下所示:

至少应在/etc/ntp.conf配置文件中设置以下参数:server

例如,使用nano文本编辑器打开/etc/ntp.conf文件:


sudo nano /etc/ntp.conf



定位服务器参数,如果为空,则按如下方式设置它:


server pool.ntp.org




server 0.ubuntu.pool.ntp.org


server 1.ubuntu.pool.ntp.org


server 2.ubuntu.pool.ntp.org


server 3.ubuntu.pool.ntp.org



然后保存文件,并重新启动ntpd服务:


sudo /etc/init.d/ntpd start



可以使用以下命令立即将系统时钟与NTP服务器同步:


sudo ntpdate pool.ntp.org



或者刚刚运行已经定义了服务器


sudo ntpdate 0.ubuntu.pool.ntp.org



或使用server定义的其他服务器

通常地


sudo ntpdate <one of the servername in /etc/ntp.conf>



但在那之后你得到错误 NTP socket in use 如下所示:


ntpdate -u pool.ntp.org 



运行ntp deamon时更新

或者停止deamon,更新,并再次启动,如下所示:


sudo ntpdate pool.ntp.org


sudo service ntp stop


sudo ntpdate pool.ntp.org


sudo service ntp start




答案4

使用htpdate

如果在网络中阻止ntp传输,请安装htpdate,它通过http协议同步时间,


sudo apt-get install htpdate


sudo htpdate -a google.com



安装软件包时将启动htpdate服务,如果有互联网连接,时间将立即更新。


答案5

绕过被防火墙的ntp端口:


sudo date -s"$(curl http://s3.amazonaws.com -v 2>&1 | 


 grep"Date:" | awk '{ print $3"" $5"" $4"" $7"" $6" GMT"}')"




答案6


ssh localhost"sudo apt-get install ntp ntpdate ; sudo service ntp stop; sudo ntpdate 0.ubuntu.pool.ntp.org; sudo service ntp start"



为此,你需要安装openssh-server

另外,删除ntp和ntpdate ( sudo apt-get remove --purge ntp ntpdate



Server  时间  syn  NTP  ntpd  
相关文章