0

I am working on a NTP client(Linux PC) to synchronize the time from NTP server(Linux PC). The NTP server in turn will synchronize the time from router.

Router <- NTP server(Linux Machine) <- NTP client(Linux Machine)

My issue is when we power on the complete setup at a time, NTP client fetches/updates its date/time from NTP server before the NTP server update its date/time from Router. I know we can restart the NTP service and force reset date/time using NTP commands in NTP client using ntpdate/"ntpd -gq". But I am not using any commands.

Is there any way that NTP client can fetch and update the date and time from NTP Server continuously every 30seconds automatically using ntpd service?

I configured NTP client to get the time from NTP server in /etc/ntp.conf: server <SERVER_IP> iburst Because of this issue the NTP client's date/time is always not in sync with NTP server/Router.

14
  • Are you asking how to configure the NTP client on Windows? If so, I suggest superuser.com or if this is a professional setting (seems to be), serverfault.com. Apr 16, 2021 at 6:16
  • 1
    Your question makes it sounds like you are coding your own NTP server? If not which one are you trying to configure? Both "ntpd" and "chrony" automatically update every two minutes or faster if your system clock's jitter is a mess. systemd-timesync is an SNTP client (so much less accurate) but this too synchronises periodically to ensure the time is kept correct. Apr 16, 2021 at 6:46
  • 1
    NTP server and NTP client are linux systems. I am using ntpd service in both client and server. NTP client is able to fetch date/time only after boot up which is only once. Later if I change the time in NTP server, the NTP client is not getting the updated date/time in NTP server. Apr 16, 2021 at 7:01
  • Do any of these devices have real time clocks? And you use ntpdate to set the clocks before turning on or restarting ntp? Also, do you run ntpdate multiple times until the ntpdate indicates the maximum time resolution has been obtain? Where does the router get it's time from? Apr 16, 2021 at 8:02
  • @CinaedSimson why should you run ntpdate before turning on NTP? Apr 16, 2021 at 8:33

1 Answer 1

1

Something about this question doesn't quite add up.

By default Ubuntu uses systemd-timesyncd. I believe it's default configuration uses a dedicated NTP server pool from ntp.org.

Systemd-timesyncd is an SNTP client which is less precise than an NTP client but good enough for most end-user machines. This will periodically poll for the time automatically. So on this point your question does not make much sense.

However (I believe) the default maximum interval is just over half an hour (2048 seconds). So if the clock synchronises incorrectly on startup it could be quite a up to 30 minutes before it corrects itself. You can reduce this time with the PollIntervalMaxSec configuration in /etc/systemd/timesyncd.conf. See the manual... at the command line type man 5 timesyncd.conf.


Note that by default systemd-timesyncd is setup to accept time servers given out over DHCP. This can cause them to add the router as a direct NTP server as well as taking your NTP server.


Note that a well configured NTP server should not cause problems with this, it should refuse to give a valid time to NTP clients until it's own clock has synchronised correctly.

However home routers can do bad things on NTP. I've personally witnessed home routers with no internal clock (BT Home Hub) respond to clients claiming to be stratum 1 and will do so even before they synced anything. The result of that is that rebooting the router sets clocks on the network back to a fixed date for a few minutes.

You must log in to answer this question.

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