Sunday, November 16, 2014

ntpd - Synchronizing time with only one NTP server




I have a linux machine on a network where the machine only has access to exactly one NTP server. After the time synchronization the status looks like this:



[root@test ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
3 u 8 64 17 1.397 2.510 1.954
*LOCAL(0) .LOCL. 10 l 6 64 17 0.000 0.000 0.001



My problem here is that even though the remote NTP server has way lower stratum and a decent jitter value, ntpd always picks the local clock as the time source, and in time its clock gets late. The situation remains the same, even after one day, so it's not about me not waiting enough for things to come together.



Questions:




  • is it possible to get reliable time synchronization with only one NTP server on the network? (my guess is no)

  • can I force ntpd somehow to prefer the NTP server over the local clock in this situation?


Answer



As Pawel has said, remove the local clock line in your ntp.conf. In fact, remove everything, pretty much. If you have a working, sync'ed NTP source on your local network that's willing to act as a server, then clients really only need one line in their ntp.conf, which should read




server ntp.intranet.example.com


or, for fastest syncing,



server ntp.intranet.example.com burst


(the latter puts more load on the server at service start time, but since it's your server, you can say "i permit that", if you want faster syncing at ntpd start time).




Don't forget to put ntp.intranet.example.com in /etc/ntp/step-tickers, or wherever your distro keeps that file, so the clocks of clients can be hard-synced at startup time.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...