Ntpd v. ntpclient issue

Hello,

I’ve been chasing down an issue with running the NTP server on my Turris Omnia (TOS 6). I believe I found a source of confusion across the forum base and hope I could get some folks to validate my findings.

Steps to reproduce:

  • Enabled the NTP Server in LuCI → System → System → Time Syncronization. Save & Apply.

  • Via SSH/Console, check if it is running with

netstat -a -n -l |grep 123
  • See what is running under with the name ntp: ps aux -w |grep ntp
root      4179  0.0  0.0    744    36 ?        S    13:48   0:00 /usr/sbin/ntpclient -i 600 -s -l -D -p 123 -h 0.openwrt.pool.ntp.org

I believe this is the problem! ntpclient is explictly being bound to port 123 vs. using any available port. This prevents the sysntpd daemon from starting.

For extra measure, I gave it ye old reboot and see what the logs tells me:

Jan 27 18:48:42 turris root: starting ntpclient
Jan 27 18:48:57 turris procd: Instance sysntpd::instance1 s in a crash loop 6 crashes, 0 seconds since last crash

Not the most verbose logs in terms of what, exactly, is happening but indiciative.

Continuing to poke…

If I stop the ntpclient with: killall -9 ntpclient

And then manually start the sysntpd with: /etc/init.d/sysntpd restart I can verify the server is running with netstat:

netstat -a -n -l |grep 123
udp        0      0 :::123                  :::*

And once again with ps aux -w |grep ntp

root      7245  0.0  0.0   1232   548 ?        S<   14:10   0:00 /usr/sbin/ntpd -n -N -l -I br-lan.1 -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.pool.ntp.org -p 2.openwrt.pool.ntp.org -p 3.openwrt.pool.ntp.org

SO…I think ntpclient hard coding port 123 is creating a conflict with starting the ntp daemon/server. This hard coding is observed in /etc/hotplug.d/iface/20-ntpclient and has been around for 10 years according to gitlab entries…

Potential Solutions:

  • Introduce logic to have the ntpclient bind to a different port if the server is enabled.
  • Stop binding explictly to the port all together. The manpage for ntpclient says if you don’t specify, it will use any port available

Can anyone else confirm this behavior? Do I need to open a issue in gitlab?

Well, in the OpenWrt documentation is stated that if you need to use ntpd, you should disable the sysntpd service or uninstall the ntpclient.

I had gone down that route in the past and run into update issues when the package was installed. Was trying to work my way through stock turris w/o introducing any breaking behavior.

Throwing some ideas out there…if there is a way for turris to programmatically disable the ntpclient from running or having it run after sysntpd in start up sequence (those giving priority to the server if it’s enable)?

If a user enabled “Provide NTP Server” turris will:

  • kill the active ntpclient process
  • disable the /etc/hotplug.d/iface/20-ntpclient script (e.g. move it out of the directory) or give sysntpd higher priority to start first, thus claiming ownership of the port

if a user disables “Provide NTP Server” turris will:

  • enable the /etc/hotplug.d/iface/20-ntpclient script
  • stop the sysntpd daemon
  • start the ntpdclient

I’ll look go back to a full featured ntpd server as I like the idea of having more configuration control but…wanted to share my findings/thoughts in hopes it helps someone else in the community and/or sparks an idea for the turris engineers.

Hi,
Just activate the option in LUCI and every thing is fine.
The service NTP is available on port 123 on the LAN
My version is 6.3.1 on Turris Omnia 1Go