Skip to content

timesyncd: Store last-known IP address of NTP server #34230

Open

Description

@Winterhuman

Component

systemd-timesync

Is your feature request related to a problem? Please describe

Inspired by: #34220 (comment)

Commonly, all the NTP servers in timesyncd.conf are specified as domains names, however, there are some circumstances where DNS resolving fails meaning no NTP server can be contacted.

In the case of some DNS resolvers, this can actually be caused by the time being out of sync itself (usually in the case where the system has no functioning RTC clock to rely on at boot).

Describe the solution you'd like

To robustly handle hardware clock failure or DNS resolver failure/misconfiguration, it'd be useful if systemd-timesyncd could save the IP address of the last successfully connected to NTP server (e.g. /var/lib/systemd/timesync/last-known).

Then, if timesyncd fails to connect to any NTP servers after a timeout, the saved IP address could be attempted (with the appropriate log to warn admins that something isn't right with the system).

Note

I haven't considered the circumstances of how, when, or if the saved IP address should be cleared; I don't have any opinion on this part.

Describe alternatives you've considered

The other alternative I'm aware of is including IP addresses in the default FallbackNTP= list (which would be a per-distro responsibility), however, this would mean constantly needing to update the list whenever a server changes IP address, which for some network setups could be a frequent occurence.

The systemd version you checked that didn't have the feature you are asking for

256.5

Activity

  1. added
    RFE 🎁
    on Sep 2, 2024
  2. yuwata commented on Sep 2, 2024

    @yuwata
    Member

    In the case of some DNS resolvers, this can actually be caused by the time being out of sync itself (usually in the case where the system has no functioning RTC clock to rely on at boot).

    systemd-timesyncd.service sets Environment=SYSTEMD_NSS_RESOLVE_VALIDATE=0. If systemd-resolved.service is running and nss-resolve is used in nsswitch.conf, then such failure should be ignored.
    I guess the root cause of #34232 is something different.

  3. Winterhuman commented on Sep 2, 2024

    @Winterhuman
    ContributorAuthor

    To clarify, I'm not using systemd-resolved for the actual DNS record fetching, but instead, I'm pointing it to a loopback address of another DNS resolver (and that resolver does require the time to be synced at the protocol level as far as I know, aka. DNSCrypt).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFE 🎁timesync

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions