NTP server does not work

Hello.

I'm trying to setup my router

LEDE Reboot 17.01.1 r3316-7eb58cf109 / LuCI lede-17.01 branch (git-17.100.70571-29fabe2)

to act as a NTP server.

My /etc/config/system contains the following section:

config timeserver 'ntp'
option enabled '1'
list server '0.lede.pool.ntp.org'
list server '1.lede.pool.ntp.org'
list server '2.lede.pool.ntp.org'
list server '3.lede.pool.ntp.org'
option enable_server '1'

The ntpd package is intalled and ntpd service is started:

root@router:~# ps |grep ntp
911 root 688 S /usr/sbin/ntpclient -i 600 -s -l -D -p 123 -h 0.openwrt.pool.ntp.org
6689 root 1036 S {ntpd.hotplug-he} /bin/sh /usr/sbin/ntpd.hotplug-helper
6964 root 1036 S grep ntp

But nobody listens at 123 port:

root@router:~# netstat -l -n |grep 123
root@router:~#

The system log contains the following lines:

Sun May 28 22:25:16 2017 daemon.notice ntpd[7134]: ntpd 4.2.8p9@1.3265-o Fri Feb 10 01:41:43 UTC 2017 (1): Starting
Sun May 28 22:25:16 2017 daemon.info ntpd[7134]: Command line: /sbin/ntpd -g -u ntp:ntp -p /var/run/ntpd.pid -n
Sun May 28 22:25:16 2017 daemon.info ntpd[7134]: proto: precision = 3.840 usec (-18)
Sun May 28 22:25:16 2017 daemon.info ntpd[7134]: Listen and drop on 0 v6wildcard [::]:123
Sun May 28 22:25:16 2017 daemon.err ntpd[7134]: unable to bind to wildcard address 0.0.0.0 - another process may be running - EXITING

What is wrong? I do not use ipv6 at all

Other than configuring /etc/config/system, have you done any other modification? I have the same configuration, but there is no ntpclient or ntp.hotplug-helper process running in my system.

Of course, I've made a lot of configuration in my router, but nothing related to ntp.

I haven't change /etc/config/system manually. All these settings were by default.

I've installed ntpd and ntpdate packages and i've disabled sysntpd service.

ntpclient has come from ntpclient package and ntpd.hotplug-helper has come from ntpd package

  1. Post your /etc/ntp.conf
  2. check with ntpq -p (ntpq is included in package ntp-utils)

In case you get connection refused:

  • Is your sysntpd stopped and disabled? If not → disable it
  • Is your ntpd enabled and started? If not → enable and start it
  • Is port 123 UDP open? If not → open it

I solved my issue with ntpd.

I removed both ntpd and ntpclient packages and reenabled busybox sysntpd service again. it works perfectly as both ntp client and ntp server. So I don't need to switch to the separate ntpd package.

2 Likes

As a note (I know this topic is old), but I also had this issue with busybox-ntp in version 17.01.1. I used ntpd (and disabled sysntpd) until version 17.01.4.

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 127.0.0.1
# restrict -6 ::1

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

interface listen 127.0.0.1
interface listen 192.168.0.1
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 ${?}