Problem :
Linux version: Centos 7
chrony version: 3.2
chrony.conf:
driftfile /var/lib/chrony/drift
local stratum 10
server localhost
rtcsync
makestep 1.0 3
logdir /var/log/chrony
allow
This picture is about chrony:
This picture is about ntpd, why they are different:
Solution :
The offset printed by chronyc sources
is not zero, because it’s an actual NTP measurement. chronyd
sent an NTP request to itself and responded. As the delays of the messages were not perfectly symmetric, there is a non-zero offset. Trying to synchronize a client to itself is not a good idea as it may create a positive feedback loop and throw the clock off. The local stratum
directive alone is enough to serve the local time when not synchronized to a time source.
The LOCAL source printed by ntpq is different. It is specified in ntp.conf
as 127.127.1.0
. Addresses in the 127.127.0.0/16 network are special addresses for ntpd
. They specify reference clocks and the LOCAL reference clock driver always returns zero offset. While it looks like a valid IPv4 address of localhost, there are no NTP packets actually exchanged.