sonic-buildimage
sonic-buildimage copied to clipboard
Issue with NTP Server Synchronization - Clock Unsynchronized
Issue Description: Our NTP configuration is based on the guidelines provided in the SONiC documentation https://github.com/sonic-net/SONiC/blob/master/doc/ntp/ntp-design.md Facing issue in synchronizing the NTP server with the client on our system. This problem was identified when reviewing the NTP logs, which indicated a time error, specifically stating that the clock is unsynchronized.
Output of show ntp:
NTP Status Details:
Output of ntpq -p server ip_address
command used to generate the NTP logs: sudo journalctl -u ntp
Logs:
Jun 19 01:40:35 sonic ntpd[12168]: proto: precision = 0.098 usec (-23) Jun 19 01:40:35 sonic ntpd[12168]: basedate set to 2019-08-28 Jun 19 01:40:35 sonic ntpd[12168]: gps base set to 2019-09-01 (week 2069) Jun 19 01:40:35 sonic ntpd[12168]: restrict 0.0.0.0: KOD does nothing without LIMITED Jun 19 01:40:35 sonic ntpd[12168]: Listen normally on 0 lo 127.0.0.1:123 Jun 19 01:40:35 sonic ntpd[12168]: Listen normally on 1 eth0 172.30.25.103:123 Jun 19 01:40:35 sonic ntpd[12168]: Listening on routing socket on fd #18 for interface updates Jun 19 01:40:35 sonic ntpd[12168]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized Jun 19 01:40:35 sonic ntpd[12168]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized Jun 19 01:40:35 sonic ntp-systemd-wrapper[12162]: Starting NTP server in default-vrf: ntpd Jun 19 01:40:35 sonic systemd[1]: Started Network Time Service.
Additional Information:
All necessary services (ntp, hostcfgd, ntp-config) have been confirmed to be running. The server ip address is reachable via ping.
Expected Outcome:
Successful synchronization with the configured NTP server.
I am seeking community assistance to identify any potential misconfigurations or issues that may be causing the problem.
Seeking help from community who may be familiar with NTPO server config to provide recommendations..
I haven't been able to fully dig through the issue, but it may be related to how /etc/ntp.conf
is being generated. The switch I am testing on does not have a management interface (eth0) and even after adding Loopback0 with an IP it does not work as described in the NTP template.
As a workaround, I was able to manually update the source interface in the config. That seems to do the trick and allows NTP to sync.
cat /etc/sonic/config_db.json | jq .NTP
{
"global": {
"admin_state": "enabled",
"authentication": "disabled",
"dhcp": "enabled",
"server_role": "disabled",
"src_intf": "Vlan1000",
"vrf": "default"
}
}
On our chassis, when I looked at /etc/ntpsec/ntp.conf, the server config was missing. Looks like based on the sonic-mgmgt generated minigraph, some if checks in ntp.conf.j2 did not satisfy the addition of server config. The changes in PR https://github.com/sonic-net/sonic-buildimage/pull/18736 helped fix this issue for us. From sonic-mgmt, I am trying to figure out how we can set the config like iburst which is required to speed up clock sync. Without that, it takes around 1.5 to 2 mins on our chassis to sync the clock.