问题
I am trying to synchronize my clock with a NTP server by following the instructions here http://support.ntp.org/bin/view/Support/GettingStarted , but this does not work.
I am on Mac OS X El Capitan 10.11.2, and here is what I do. I picked server ntp.your.org ( http://support.ntp.org/bin/view/Servers/PublicTimeServer000498 ) and I synchronize my computer with it:
XXX-macbook-pro-2:ntp-4.2.8p6 XXX$ sudo ntpdate -b ntp.your.org
31 Mar 20:05:04 ntpdate[43114]: step time server 204.9.54.119 offset -0.005629 sec
Then to check that it works, I do
XXX-macbook-pro-2:ntp-4.2.8p6 XXX$ ntpdc -c peers
nodename nor servname provided, or not known
Also, if I do ntpq I get
XXX-macbook-pro-2:ntp-4.2.8p6 XXX$ ntpq -pcrv
nodename nor servname provided, or not known
while if I do the same by switching my internet connection to a different WIFI network, I get a different output:
XXX-macbook-pro-2:XXX XXX$ ntpq -pcrv
remote refid st t when poll reach delay offset jitter
==============================================================================
ntp.your.org .INIT. 16 u - 64 0 0.000 0.000 0.000
associd=0 status=c012 leap_alarm, sync_unspec, 1 event, freq_set,
version="ntpd 4.2.6@1.2089-o Fri May 28 01:20:53 UTC 2010 (1)",
processor="x86_64", system="Darwin/15.2.0", leap=11, stratum=16,
precision=-20, rootdelay=0.000, rootdisp=0.075, refid=INIT,
reftime=00000000.00000000 Mon, Jan 1 1900 0:09:21.000,
clock=daa9468e.835891f4 Fri, Apr 1 2016 21:12:14.513, peer=0, tc=3,
mintc=3, offset=0.000, frequency=-47.221, sys_jitter=0.000,
clk_jitter=0.001, clk_wander=0.000
Do you have any idea of what is the issue at the bottom of this?
Thank you.
回答1:
From the output you provided when you changed networks leads me to believe this is a network issue.
The original problem you posted is referenced in this post and another here. They both point towards an IP config issue - either DNS or DHCP.
It looks like port 123/UDP might be blocked either on the host machine or the network router/gateway/firewall. You need to check this, or connect to a network where you know no ports are blocked. Wired or wifi shouldn't matter unless you have different IP Config or security settings.
The fact that once you changed networks you see reach = 0
& refif = .INIT.
says that you can resolve the ntp server (ntp.your.org) but you can't connect to it.
From a working setup you would expect to see something like this below (Taken from one of my answers on SuperUser - addresses removed)
remote refid st t when poll reach delay offset jitter
==============================================================================
PRIVATE .STEP. 16 u - 1024 0 0.000 0.000 0.000
-PRIVATE1 .GPS. 1 u 55 64 377 29.585 0.071 0.312
-PRIVATE2 .GPS. 1 u 40 64 377 9.468 0.209 0.129
-PRIVATE3 1.1.1.1 2 u 12 64 377 6.943 -0.270 0.142
-PRIVATE5 .PPS. 1 u 20 64 377 16.383 -0.531 0.197
+PRIVATE6 .DCFa. 1 u 22 64 377 8.661 -0.036 0.126
-ISP1 2.2.2.2 2 u 36 64 377 11.720 -0.027 0.280
#PRIVATE7 .GPS. 1 u 47 64 377 24.781 -1.405 1.118
+ISP2 .PPS. 1 u 4 64 377 6.012 0.062 0.154
-ISP3 .PPS. 1 u 14 64 377 13.993 -0.463 0.206
-ISP4 .CDMA. 1 u 57 64 377 71.712 -0.109 0.249
ntp.mcast.net .MCST. 16 u - 64 0 0.000 0.000 0.002
LOCAL(0) .LOCL. 10 l 69d 64 0 0.000 0.000 0.000
xSHM(0) .GPS. 0 l 9 16 377 0.000 -25.278 7.907
*SHM(1) .PPS. 0 l 11 16 377 0.000 -0.030 0.060
associd=0 status=0488 leap_none, sync_uhf_radio, 8 events, no_sys_peer,
version="ntpd 4.2.6p5@1.2349-o Sat Nov 23 18:21:48 UTC 2013 (1)",
processor="x86_64", system="Linux/3.13.3-1.el6.elrepo.x86_64", leap=00,
stratum=1, precision=-19, rootdelay=0.000, rootdisp=0.435, refid=PPS,
reftime=d81f71b3.9b5a018c Tue, Nov 25 2014 21:22:59.606,
clock=d81f71be.1f3892d4 Tue, Nov 25 2014 21:23:10.121, peer=28309, tc=4,
mintc=3, offset=-0.021, frequency=-69.212, sys_jitter=0.031,
clk_jitter=0.145, clk_wander=0.031
It's worth pointing out that ntp is most happy with a minimum of 3 servers and ideally 5 for it to work correctly, and pick the 'best' timing source accordingly.
The docs here will help with what some of the other fields relate too.
I'm also thinking this question should be migrated to SuperUser as its not a programming related question.
来源:https://stackoverflow.com/questions/36340646/cannot-connect-to-ntp-server