System time not updated on restart

I am using OpenWrt 21.02.1 (with LuCi) on Linksys WRT1900ACSV2.

The system time does not update upon restarting the router. NTP client enabled, Use DHCP advertised servers enabled and default NTP servers enabled.

How can I fix this - any suggestions?

Thank you.

From the OpenWrt docs:

If you can't wait, you could use ntpdate to set the correct time immediately after reboot.

opkg update
opkg install ntpdate
data="/usr/sbin/ntpdate 0.openwrt.pool.ntp.org\nexit 0"
sed -i "s~exit 0~$data~g" /etc/rc.local
reboot

I assume that your NTP configuration is correct and working.

1 Like

Thanks for explaining and the hint!

Indeed the system works as you described above from the OpenWrt docs - checked it.

The culprit is AdGuard Home. Once I start forwarding DNS requests to this app, OpenWrt system time is no longer updated.

Other than DNS forwarding, the only setting changed are new custom rules in firewall:

iptables -t nat -A PREROUTING -i br-lan -p udp --dport 53 -j DNAT --to [AdGuard Home IP : port]
iptables -t nat -A PREROUTING -i br-lan -p tcp --dport 53 -j DNAT --to [AdGuard Home IP : port]

I do not immediately see why AdGuard Home is preventing getting correct system time from default servers. Probably, the question belongs to AG forum rather than OpenWrt forum.

Still, if any idea - please let me know! Thanks.

It is best to enable split DNS and configure DNS forwarding to the AdGuard socket.
Then resetting interface DNS settings to defaults should solve the race condition.

You might need to whitelist the ntp.org NTP servers...

1 Like

Thanks for suggestion, but this did not work. No update even with all blocklists off in AGH.

Thanks for your reply!

I am afraid my knowledge of OpenWrt and DNS/DHCP is not sufficient to fully understand the execution of the idea. I checked the "Ignore resolve file" in LuCi, forwarding to AGH socket has been set. But to no avail...

Did you mean split DNS as a fallback when AGH is not available? Or splitting requests between AGH and rooter depending on the request type? I have the rooter set as DHCP, not AGH.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.