Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 2605

Raspberry Pi OS • systemd-timesyncd fails sync time for minutes after boot - possible DNS problem?

$
0
0
Hello,

I'm advanced Linux user, who's recently built a new system on an RPI 4B. This is the first time I've used Raspberry Pi OS based on bookworm (I have an older Pi due to some dependant software which this will replace).

I've always used chronyd for time, but since this is a lightweight build my pi is using the default systemd-timesyncdservice for synchronising time. Since the pi doesn't have an RTC setting the time on boot is really important, but my system consistently takes a random number of minutes before it synchronises the time on boot!

This problem has only occured when I changed from using the default pool to my own internal NTP server. However the problem isn't with my NTP server nor my DNS caching server.

I've dug further and found that on boot the pi performs a DNS query for my NTP server but it fails to attempt a connection for a lengthy time (often many minutes). The problem appears to be related to DNS, as my NTP server name is a CNAME for another server. If, immediately after boot, I attempt to ping the NTP CNAME, ping returns "Name or service not known". However if I then ping the server's name (that is the name the CNAME refers to) then I can ping the NTP CNAME again and it works. Following this systemd-timesync appears to sync the first time.

If I change /etc/systemd/timesyncd.conf to use my local NTP server by IP address, the problem does not occur - time is synchronised within a few seconds or so.

In summary:
  • Pi running default systemd-timesyncd software, only changed to use local NTP server, fails to sync time on boot for many minutes after boot (possibly never syncs?)
  • The NTP server is flawless and serves many other systems. It does not appear to recieve NTP queries from the Pi when the problem happens
  • The DNS server is flawless and when queried by the Pi for the local NTP server, returns the CNAME record within 1 ms.
  • However, until I manually trigger the DNS resolution of the host the CNAME points to, systemd-timesyncd doesn't appear to sync quickly.
  • If systemd-timesync is configured to use the NTP server by IP it works quickly after boot.
  • /etc/resolve.conf is the default, configured by NetworkManager and my internal doman is NOT .local so not using MDNS for discovery, but instead using my DNS server.
I'd really prefer to use my internal NTP server and refer to it by CNAME, rather than IP. Does anyone have any suggestions for what I should investigate?

Thank you!

Statistics: Posted by Legendary Rye — Sat Jan 04, 2025 6:21 am



Viewing all articles
Browse latest Browse all 2605

Trending Articles