when will sysntpd sync time?
when with CPE, sometime it does not get the new date.
killall tcpdump; \
tcpdump -eni any udp port 123 & \
/etc/init.d/sysntpd restart
service_triggers()
{
procd_add_reload_trigger "system"
procd_add_validation validate_ntp_section
}
is there another way?
what does it mean that procd_add_reload_trigger "system"
It should do so automatically, but since ntpd was put in a ujail (commit 2d34355e16b442fcf51e93786401716dae3c4ea2), it will not work on first boot due to a race condition if you are using an external DNS resolver for the host in question (i.e., no 127.0.0.1 in /etc/resolv.conf
).
opened 09:57AM - 29 Sep 22 UTC
I don't want to file a bug report under packages because I've not been able to f… ind the package for `ntpd`. I'm running `OpenWrt 22.03.0 r19685-512e76967f` . My device is `TP-Link TL-WDR3600 v1`. After a sysupgrade the date was set to September 3rd, 2022. Today it's the 29th of September.
Of course `opkg update` failed with `wget returned 5`.
I couldn't find a command to sync the time in a SSH session, so I simply ran `/etc/init.d/sysntpd restart` which fixed the issue. I waited at the very least 10 minutes for the time to sync automatically. Didn't happen.
Please make sure after a sysupgrade time is indeed getting synced.
There are zero `ntp` related messages in the System Log.
I've never touched any NTP related settings, everything is AFAIK by default. My Internet connection is working perfectly.
![ntp](https://user-images.githubusercontent.com/4958603/193002311-523695dc-a012-4e69-ade4-4c7eb2beaedf.png)
... with the main bug dealing with /etc/resolv.conf
race conditions being ...
opened 09:41PM - 04 Aug 22 UTC
The `/etc/resolv.conf` within a jail is a bind mount of the real `/etc/resolv.co… nf`. If `/etc/resolv.conf` (or the destination of the symlink) is replaced, then that change won't be visible within the jail (it still sees the old file).
As long dnsmasq is installed and used as local resolver that is not an issue, as `/tmp/resolv.conf` doesn't change in this case (it specifies 127.0.0.1 and ::1, so only dnsmasq has to care about the real nameservers).
However, it is a problem if there is no local resolver, as the link then points to `/tmp/resolv.conf.d/resolv.conf.auto` which can get replaced during normal operation, for example when `/etc/init.d/network` is started or stopped. This means that if a jailed service is started while the network is not (yet) configured, it will never have working DNS (`resolv.conf.auto` is empty in that case, so DNS queries will always be sent to localhost, and fail if there is no local resolver).
The actual example where I found this issue is sysntpd, which as a result won't ever synchronize the time if it is started before nameservers are configured.
Workaround
Start ntpd directly, without jail
How
# mv /etc/capabilities/ntpd.json /etc/capabilities/ntpd.json-disabled
# service sysntpd restart
Root cause
procd and jail on routers without dnsmasq
#10843 - Time is not synced on (re)boot automatically after a sysupgrade to 22.03.0
#10389 - ujail: changes to resolv.conf may not be reflected in jail
In the detail
Time synchronization among active network devices is essential and critical.
Example: network with multiple Dumb APs
# echo "Diagnostics commands"
# tcpdump -v -n port 123
# grep resolv /proc/`ps | grep '/usr/sbin/ntpd' | grep -v grep | awk '{ print $1 }'`/mountinfo
Unsuccessful workarounds
/etc/init.d/sysntpd # USE_PROCD variable is not evaluated
Package ntpd is too big to fit into memory (openssl on 8MiB AP with wolfssl)
Package ntpclient
does not regularly check ntp server
uses NTPv3 (sysntpd NTPv4)
2023-01-05T23:00:00Z
1 Like