Monthly Archives: March 2014

how server in china pissed me when configuring ntp for Raspberry Pi

so i got a Raspberry Pi recently and when compiling stuff, i got the time screwed error, clearly the system time is not right as rpi don’t have a hwclock.

after some easy googling i know i can use ntp to sync time with network  server whenever rpi boots, then i got this page to guide me through the set up. after some messing around and reading the whole article several times, i found my problem is ntpd -qg simply won’t return.

as you can read from that article, ntpd -qg should say “ntpd: time set +%%%%%%s” in the end, but i can’t get that message. running with some debug information with ntpd -qgd showed the ntpd seems can’t get a answer from the server, so i’m still in 1970.

then i find the official page and get more dump commands. ntpq -p gives a abnormal output: all delay, offset, jitter is 0, and the refid is .INIT., this is very bad. then i tried ntpdate pool.ntp.org, and it tells me there is no suitable server to sync the time, omg!

in /etc/ntp.conf, you can check which server ntp is using. mine is the default one: 0.pool.ntp.org, 1.pool.ntp.org, 2.pool.ntp.org, there should be some redirecting stuff, you can see with ping 0.pool.ntp.org, the address i get starts with 202., so it’s a china server(also from the domain name). it’s sensible because it always choose the closest one for you. now that is the problem, how can i trust a chinese server to deliver ntp service properly?

now the solution would be pretty obvious: use a eu or us server. just prepend pool. with us., you got 0.us.pool.ntp.org, 1.us.pool.ntp.org, 2.us.pool.ntp.org. this time ntpd -qgd would happily tells me it has got the time set properly, and ntpq -p also prints sensible results.

welcome back to 2014!

Advertisements