2

Because the clocks of multiple of my Debian/KDE machines went off by many minutes for no apparent reason and common mainboards (or at least the one that I have) don't have accurate, reliable hardware clocks, I had to set up openntp.

With openntp there are constantly connections to ntp servers (check with sudo lsof -i) with various implications for e.g. attack-surfaces of devices and privacy. I'd like to keep Internet-connections minimal and would like to prevent all network activity which I don't need/doesn't have any use. I'd just like to have a working clock for everyday use so I don't think all of this is really needed:
there must be a better and simpler way to get a working clock on GNU/Linux/Debian.

Two such ways I can think of would be:

  • having openntpd only connect to ntp servers every z minutes (a random number between x and y), sync the clock and then shut down again.
  • in a similar way fetching time information from a few authenticated web-servers and only if the clock drift seems to be too large, having openntpd connect to ntp servers and sync the clock.

Maybe there are better ways like new reliable hardware clocks. I think one of these two ways could be easy to configure. Is something like this possible / how can something like this be done?

2
  • NTP is designed so that as your clock synchronises more accurately it queries upstream servers less often. My primary is currently polling at 1024 seconds, i.e. a burst of four UDP packets each way to each of my upstream servers every 15 minutes or so. I could increase the interval by powers of two from 2^10 seconds to 2^17 (approximately 36 hours) if I so chose Feb 9, 2021 at 15:25
  • I don't think that this applies to openntpd. At least I couldn't find a way to configure the polling interval. This Q&A suggests that info about the polling can be retrieved with ntpq and found in ntpd.conf but I have neither that command/binary, nor a ntpd.conf file.
    – mYnDstrEAm
    Feb 9, 2021 at 19:27

2 Answers 2

2

You can try to adjust the poll values in ntp.conf

minpoll minpoll, maxpoll maxpoll
    These options specify the minimum and maximum poll intervals 
    for NTP messages, in seconds as a power of two. The maximum 
    poll interval defaults to 10 (1,024 s), but can be increased 
    by the maxpoll option to an upper limit of 17 (36.4 h).
    The minimum poll interval defaults to 6 (64 s), but can be 
    decreased by the minpoll option to a lower limit of 4 (16 s).
    These option are valid only with the server and peer commands.

Alternatives such as systemd's timesyncd also have polling interval options in timesyncd.conf:

PollIntervalMinSec=, PollIntervalMaxSec=
    The minimum and maximum poll intervals for NTP messages. Each
    setting takes a time value (in seconds).  PollIntervalMinSec= must
    not be smaller than 16 seconds.  PollIntervalMaxSec= must be larger
    than PollIntervalMinSec=.  PollIntervalMinSec= defaults to 32
    seconds, and PollIntervalMaxSec= defaults to 2048 seconds.

And you can check what it's currently using:

$ timedatectl show-timesync --all
[...]
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=34min 8s

Unless your clock is actively misbehaving, it should go to the max polling interval on its own accord.

There is also the option of using a NTP client (like ntpdate) in a cron job or similar. This way it will only update the clock on the intervals you specify, regardless how out-of-sync it may be.

If you have a misbehaving clock on this device but also another device in your local network that is able to keep its clock better, you could use it as a local timeserver instead. That would give you one device that rarely polls internet servers, and gets frequently polled locally. Such a local timeserver would allow you to minimize exposure to the outside world.

No matter which option you choose, make sure the system clock is correct at all times.

2
  • 1
    When running timedatectl show-timesync I get Failed to parse bus message: No such file or directory. Openntpd doesn't use ntp.conf: I only have /etc/openntpd/ntpd.conf and there doesn't seem to be a setting to polling. I thought a cronjob may be part of the solution if there is no built-in support for this. Multiple Debian machines don't have a working clock and I haven't figured out why or how to solve it except with openntpd.
    – mYnDstrEAm
    Feb 9, 2021 at 13:37
  • @mYnDstrEAm You're right of course. Sorry for mixing up ntp implementations. I had a blink at openntpd source and it does not seem to be customizable at runtime. So you'd either have to use a local timeserver or something else entirely. Feb 9, 2021 at 14:21
0

The solution was to upgrade to Debian12, remove openntpd, and install timesyncd as described here.
The default options can be shown with timedatectl show-timesync as frostschutz' helpful answer shows and these options can be modified by editing /etc/systemd/timesyncd.conf but seem to be good enough to have a working clock.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .