NTP server does not work

I believe that I've just found a bug.

In https://github.com/lede-project/source/blob/master/package/utils/busybox/files/sysntpd
it use PROG=/usr/sbin/ntpd

However, the program is available under /sbin/ntpd but not /usr/sbin/ntpd.
and it does not accept argument "-S" .

Only ntpd 4.2.8p9-2 is installed.
No ntp-utils, ntpdate, nor ntpclient is installed in my system.

Uninstall of ntpd seem fix everything.

It feel like ntpd is broken and it should not broke sysntpd.

Well /etc/init.d/sysntpd is the init script for busybox' builtin ntp server. If you install a standalone ntpd, it should ship its own init script (/etc/init.d/ntpd or similar).

1 Like

There was no /etc/init.d/ntpd.

Even so, installation of ntpd should "disable" not "broke" sysntpd

same problem here. I think - it was working fine until I installed: luci-app-ntpc and ntpclient
since then the ntp server is no longer working on the device. I removed ntpclient again, tried it, and also switched to ntpd and ntp-utils without any luck.

default config. I saw some entries in the logs regarding the command line:

/sbin/ntpd -g -u ntp:ntp -p /var/run/ntpd.pid -n -c /var/etc/ntpd.conf

still - there is no ntp related process running, port 123 is not in use, and there is no service responding to any ntpclients from the network.

If I start that command line listed in the logs, everything works as expected - but starting it from the startup section, does not yield any new processes or error logs.

this is how i check for listening ports:

netstat -Wpn -l -a | grep :123

config /var/etc/ntpd.conf

driftfile /var/lib/ntp/ntp.drift

# default config
# restrict default limited kod nomodify notrap nopeer
# restrict -6 default limited kod nomodify notrap nopeer

# No limits for local monitoring
# restrict
# restrict -6 ::1

# modified config
restrict default ignore
restrict mask limited kod nomodify notrap nopeer noquery
restrict source noquery

interface listen
interface listen
interface drop IPv6

server time.cloudflare.com iburst

I tried the default and the modified configuration - both only works if I start the process manually - but both fail to start automatically or via the uci startup interface.

What version of OpenWrt and ntpd?

OpenWrt 19.07.3 r11063-85e04e9f46
ntpd 4.2.8p15-1

1 Like

I use chrony, it's smaller than the ntpd suite.

If you are using ISC ntpd, then disable BusyBox sysntpd to avoid conflicts:

/etc/init.d/sysntpd disable
/etc/init.d/sysntpd stop
/etc/init.d/ntpd enable
/etc/init.d/ntpd start

Unfortunately, no change.

Also: is the luci function under system>startup doing something different?

1 Like

Try to avoid using interface/socket binding.

Mmh. Ok
I removed that and started again. Still no processes running and no errors in the logs

1 Like

Post the output:

ubus call system board; opkg search $(readlink -f $(type -p ntpd)); \
/etc/init.d/log restart; /etc/init.d/ntpd restart; sleep 10; logread -e ntpd; \
pgrep -f -a ntpd; netstat -l -n -p | grep -e ntpd; \
grep -v -e ^# -e ^$ /var/etc/ntpd.conf; \
uci show system.ntp; \
/etc/init.d/sysntpd enabled; echo ${?}; \
/etc/init.d/ntpd enabled; echo ${?}
        "kernel": "4.14.180",
        "hostname": "charon",
        "system": "ARMv7 Processor rev 0 (v7l)",
        "model": "TP-Link Archer C2600",
        "board_name": "tplink,c2600",
        "release": {
                "distribution": "OpenWrt",
                "version": "19.07.3",
                "revision": "r11063-85e04e9f46",
                "target": "ipq806x/generic",
                "description": "OpenWrt 19.07.3 r11063-85e04
ntpd - 4.2.8p15-1
driftfile /var/lib/ntp/ntp.drift
restrict default ignore
restrict mask limited kod nomodify
 notrap nopeer noquery
restrict source noquery
server iburst
server time.cloudflare.com iburst
1 Like

Also, i don't understand the init script. It seems to reset the ntpd config file when starting an instance but the file remains unchanged. I don't know how to debug that :frowning:

If that helps: the directory /var/lib/ntp/ is empty. Even stays empty if i start that command manually.

Enable the UCI section and add the NTP servers:

uci set system.ntp.enabled="1"
uci set system.ntp.enable_server="1"
uci -q delete system.ntp.server
uci add_list system.ntp.server="0.openwrt.pool.ntp.org"
uci add_list system.ntp.server="1.openwrt.pool.ntp.org"
uci add_list system.ntp.server="2.openwrt.pool.ntp.org"
uci add_list system.ntp.server="3.openwrt.pool.ntp.org"
uci commit system
/etc/init.d/ntpd restart

See also:

Note that the /var config is runtime, so do not edit it.

1 Like

That's it. I didn't read the readme :frowning:

Everything is working now. But it says it's 4am already.. so i better go to bed now.

Thank you very much for your help.

1 Like

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