Hello,
This tutorial will guide you to set the router to NTP (network time synchronization) server and overwrite it to the LAN client's NTP service (Including the LAN port and WiFi clients) .
There is no need to change the NTP server configuration on all clients. As long as the client is connected to the router LAN port or main WiFi, when it needs to sync time, it will be responded by the router's NTP server and provide the time sync service.
-
Check whether the router system time is correct:
date
# If the time is not sync, you can trigger it manually:
/etc/init.d/sysntpd restart
- Enable NTP server of router:
uci set system.ntp.enable_server='1'
uci commit system
/etc/init.d/sysntpd restart
- Using the help of firewall rules, all NTP requests from listening to LAN clients are redirected to the NTP server of the router itself:
iptables -t nat -A PREROUTING -i br-lan -p udp --dport 123 -j DNAT --to-destination [Router LAN IP]:123
# Please use your router's actual LAN IP. 123 is a fixed NTP service port.
# For example, the router LAN IP of the NTP server is 192.168.8.1.
iptables -t nat -A PREROUTING -i br-lan -p udp --dport 123 -j DNAT --to-destination 192.168.8.1:123
- Check whether the firewall rule is added and whether the port is starting to listen:
iptables -t nat -L PREROUTING -v
netstat -uln | grep 123
![]()
![]()
- Add the above firewall rule to
/etc/rc.local, ensure the rule always takes effect after router restart:
sed -i '/^exit 0$/i iptables -t nat -A PREROUTING -i br-lan -p udp --dport 123 -j DNAT --to-destination 192.168.8.1:123' /etc/rc.local
- Verify whether to obtain the time information of the NTP server of the router in Windows PowerShell (Arbitrary public IP/domain)
w32tm /stripchart /computer:www.google.com /dataonly /samples:3
w32tm /stripchart /computer:123.123.123.123 /dataonly /samples:3
-end
