I would like to use the Omnia as IoT central for my own ESP8266 and ESP32 based projects. All of my planned projects so far will need the local time. Some of them will go to deep sleep and wake up every 5 minutes only for a few seconds and it will be multiple devices doing so. In the ESP8266 world, “wake up from deep sleep” means device reset, querying the time again. I was told that the NTP servers in the internet may block my IP when they receive too many requests.
The (probably only) solution to that is a local NTP server.
I’ve followed the instructions in How to activate the NTP server? and at first it seemed to work. But after rebooting the Omnia next time, it stopped working. According to /var/log/messages, ntpd could not start because port 123 was already taken. According to netstat, it is ntpclient.
Well … I’ve uninstalled ntpclient as stated in the instructions. But there are two problems with that:
During uninstall (via LuCi), it warned me that this is a required package and it will return. Obviously, it did.
It is running although it’s not listed in System -> Startup (again LuCi)
So how can I get rid of ntpclient or at least disable it permanently ?
the client component of ntp would/should not have a listening socket/port open, only the server component should do.
Which ntp package(s) did you install and how, e.g. via LuCI - which runs opkg install - or pkgupdate?
What is the output of opkg list-installed | grep ntp?
bysubox is providing both ends of ntp - client and server. Whilst former usually works out of the box latter needs to be manually activated in /etc/config/sytem, there is currently no option in Foris/LuCi
Indeed, the enable_server '1' line was missing in my /etc/config/system, but adding it and rebooting the Omnia did not change anything:
root@turris:~$ grep ntp /var/log/messages
2019-06-12 21:09:29 err ntpdate[2379]: name server cannot be used: Try again (-3)
2019-06-12 21:09:29 notice root[]: starting ntpclient
2019-06-12 21:09:35 notice ntpdate[2588]: step time server 176.9.100.86 offset 0.013785 sec
2019-06-12 21:09:41 notice ntpd[3649]: ntpd 4.2.8p13@1.3847-o Thu Apr 11 14:04:22 UTC 2019 (1): Starting
2019-06-12 21:09:41 info ntpd[3649]: Command line: /sbin/ntpd -g -u ntp:ntp -p /var/run/ntpd.pid -n
2019-06-12 21:09:41 info ntpd[3649]: proto: precision = 0.800 usec (-20)
2019-06-12 21:09:41 info ntpd[3649]: basedate set to 2019-03-30
2019-06-12 21:09:41 info ntpd[3649]: gps base set to 2019-03-31 (week 2047)
2019-06-12 21:09:41 info ntpd[3649]: Listen and drop on 0 v6wildcard [::]:123
2019-06-12 21:09:41 err ntpd[3649]: unable to bind to wildcard address 0.0.0.0 - another process may be running - EXITING
2019-06-12 21:09:51 info procd[]: Instance sysntpd::instance1 s in a crash loop 6 crashes, 0 seconds since last crash
Whow, some success. Now it starts. I also had to restore the symlink /sbin/ntpd pointing to /bin/busybox. This symlink was removed when I installed ntpd.
There is just one thing … it only works on LAN, but not on WLAN. And the netstat line looks a bit strange, at least for IPV4.
I’ll check the firewall thing tomorrow, going to bed now. But I have to admit I’m surprised that this matters at all … I thought that ntpd (OK, busybox) would listen on all interfaces.
For your curiosity … I did not test on the router. I tested on the PC (for LAN) and the Laptop (for WLAN). This is the output on the PC:
root@PC:~$ ntpdate -q turris
server 192.168.1.1, stratum 2, offset -0.000711, delay 0.02785
12 Jun 22:17:44 ntpdate[29545]: adjust time server 192.168.1.1 offset -0.000711 sec
Whow, that’s interesting … ntp does not exist (or not exist anymore):
root@turris:~$ ntpq -p
-ash: ntpq: not found
Could it have been part of the ntputils package that was uninstalled implicitly when I uninstalled ntpd and ntpclient?
What’s even more strange … I can’t find ntpd and ntputils anymore. Neither in LuCi nor with opkg. In between, I ran opkg update, maybe this is how I lost these packages from the list.
At least, I can run
root@turris:~$ ntpdate -q localhost
server 127.0.0.1, stratum 2, offset 0.000014, delay 0.02766
13 Jun 21:44:00 ntpdate[21172]: adjust time server 127.0.0.1 offset 0.000014 sec
on the TO and I get a similar result as on the PC.
Later on when you want install other packages just extend Install("ntp-utils", "package name") and run pkgupdate again. For removal just delete the package name from that file, save and pkgupdate again.
And if you want to uninstall packages that came pre-installed add e.g. Uninstall( "openssh-sftp-client", "openssh-sftp-server").
With the output of ntpdate [host], ntpq -p, ntptime -c and ntpdc -lnps I am growing concerned that that the ntpd server implementation in busybox is flawed. At least all the output seems to be indicative of it.
It might turn out not to be a bug but rather some misconfig on my end, but I do not see where really.
And ntpdate -q does not prove to me that the server is actually (capable of) serving time to clients and everything else seems to be pointing to the contrary. Which is not a reliable scenario really to depend on
And thank you for your feedback, establishing that the output is not just happening on my node.