Trying to query OpenWrt's built-in NTP daemon using ntpq but nothing received

[OpenWrt 19.07.3 on Netgear WNDR3800]

Edit: This question was based on my misunderstanding of the NTP user guide linked below. The NTP utilities mentioned in the user guide are not compatible with OpenWrt's built-in BusyBox NTP daemon but instead requires that you switch to the full ntpd packages also mentioned in the guide. As you can see later in this discussion my needs were fulfilled by instead using OpenWrt's hotplug interface for my NTP needs.

I am trying to query the NTP daemon according to the description at:

NTP config is left at stock settings so I am assuming it is using busybox ntpd.
I have enabled NTP server mode so ntpq can talk to it:

uci set system.ntp.enable_server="1"
uci commit system
/etc/init.d/sysntpd restart

and installed the ntp-utils package:
opkg install ntp-utils

but running ntpq times out:

root@router:~# ntpq
ntpq> peers
localhost: timed out, nothing received
***Request timed out

What's wrong?


If you're using ntpq are you using Busybox's NTP server?

Did you explicitly disable the Busybox one and enable the Reference Version?

Did you install ntpd also?

1 Like

I'm sorry and I apologize for maybe not understanding the instructions at:
but the text seems to suggest that busybox-ntpd is the pre-installed NTP daemon in OpenWrt?

Whichever is the default ntpd in OpenWrt I just want to be able to run ntpq to query it, and thus I followed the instructions about installing the ntp-utils package. Do I need to take other steps?

Correct, it does suggest that...and then you proceeded to install ISC's NTP tools; and you seem to be inquiring why they don't work on Busybox's implementation...I think I have that accurate.

:confused: Why do you believe you can run ISC's tools on Busybox's software?

Yes. The solution is as stated above:

BTW, you should be able to query the server with the ISC installed tool:

ntpdate -q

Hope this helps.

1 Like

Ah ok, so do I understand correctly that there is no tool to query the NTP status of the Busybox software?

(I was not primarily looking for replacing the NTP daemon but it sounds like I need to do that to be able to get the query function...?)

1 Like
root@OpenWrt:~# ntpd -h
ntpd: unrecognized option: h
BusyBox v1.31.1 () multi-call binary.

Usage: ntpd [-dnqNwl] [-I IFACE] [-S PROG] [-p PEER]...

NTP client/server

        -d      Verbose (may be repeated)
        -n      Do not daemonize
        -q      Quit after clock is set
        -N      Run at high priority
        -w      Do not set time (only query peers), implies -n
        -S PROG Run PROG after stepping time, stratum change, and every 11 min
        -p PEER Obtain time from PEER (may be repeated)
        -l      Also run as server on port 123
        -I IFACE Bind server to IFACE, implies -l

I don't see it...and doubt it, especially when the -h argument isn't programmed either.

If you want to see the NTP peer information and status via running software in the ISC NTP Utility Suite ntp-utils, then yes, you'd need to be running the accompanying ISC NTP Server Suite ndpd as well.

1 Like

Ah right, thanks. I discovered it is sort of possible to check the BusyBox NTP setup by running its ntpd as a new process. You need ti get the settings from /etc/config/system and supply the -w flag to avoid fighting about setting time with the already running instance. This is what you get:

root@router:~# ntpd -w -p -p
ntpd: reply from offset:+0.008095 delay:0.060098 status:0x24 strat:2 refid:0xc23acc94 rootdelay:0.005066 reach:0x01
ntpd: reply from offset:+0.037367 delay:0.090609 status:0x24 strat:2 refid:0xc0248f82 rootdelay:0.001602 reach:0x01
ntpd: reply from offset:+0.007746 delay:0.046828 status:0x24 strat:2 refid:0xc0248f82 rootdelay:0.001602 reach:0x03

I understand now that BusyBox doesn't have any IPC or RPC interface to query the status of the running NTP daemon.

BUT the OpenWrt built-in configuration does have a hotplug interface for NTP:
that provides an event-based API for me to get the information I need (basically getting to know when the router has been setup with synced time).

So the solution for me will be to keep the built-in NTP and add a script to /etc/hotplug.d/ntp.

1 Like

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