Dumb AP not syncing time

Wondering why my dumb access point doesn't seem to be asking for the date/time from the ntp server like my main router does. It is currently over 90 minutes off the real time. I have the dumb AP setup to do so and the daemon is running:

# /etc/init.d/sysntpd status
running

Is the gateway and DNS defined/configured correctly on the AP? You could try filling in the IP address instead (just to try if its a DNS issue).

2 Likes

I had that DNS/gateway issue yesterday on a similar topic, the solution is here, to check if it solves your issue as well: [Solved] Zone and interface requirement for SW download to device - #8 by psherman

I finally gave up and added a time server to my local net.

On router and dumb AP I just point to the local server’s ip. Probably not needed, but I also run a cron every hour on the router to call ntpdate to step the clock.

The thing is, if I manually run the following command, the time is correctly set. It is just not getting set by the sysntpd daemon.

Here is on a fresh boot today, Sat Sep 9 13:20:

# date
Thu Sep  7 06:16:05 EDT 2023

The date is off by several days as you see. Manually restarting the daemon fixes the time. Why is it not getting setup on boot?

# /etc/init.d/sysntpd status
running

# /etc/init.d/sysntpd restart
# date
Sat Sep  9 13:03:35 EDT 2023

Please run the following commands and paste the output here, using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have

ubus call system board
uci export system
uci export network
ls -l  /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*
head -n -0 /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*
nslookup 0.openwrt.pool.ntp.org

cat /etc/rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

if [ -x /root/update_date ]; then
at -f /root/update_date now+2minutes 2> /dev/null 1> /dev/null
fi

cat /root/update_date

/etc/init.d/sysntpd restart

set file permission

chmod 700 /root/update_date

view document:

Here is everything you requested:

output
# ubus call system board
{
	"kernel": "5.15.131",
	"hostname": "serenity-switch",
	"system": "MediaTek MT7621 ver:1 eco:3",
	"model": "TP-Link Archer A6 v3",
	"board_name": "tplink,archer-a6-v3",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "SNAPSHOT",
		"revision": "r0+23896-7f14304b28",
		"target": "ramips/mt7621",
		"description": "OpenWrt SNAPSHOT r0+23896-7f14304b28"
	}
}
root@serenity-switch /root # uci export system
package system

config system
	option ttylogin '0'
	option log_size '64'
	option urandom_seed '0'
	option compat_version '1.1'
	option hostname 'serenity-switch'
	option log_proto 'udp'
	option conloglevel '8'
	option cronloglevel '5'
	option zonename 'America/Detroit'
	option timezone 'EST5EDT,M3.2.0,M11.1.0'

config timeserver 'ntp'
	list server '0.openwrt.pool.ntp.org'
	list server '1.openwrt.pool.ntp.org'
	list server '2.openwrt.pool.ntp.org'
	list server '3.openwrt.pool.ntp.org'

config led 'led_lan'
	option name 'LAN'
	option sysfs 'green:lan'
	option trigger 'netdev'
	option dev 'br-lan'
	list mode 'link'

config led 'led_wan'
	option name 'WAN'
	option sysfs 'green:wan'
	option trigger 'netdev'
	option dev 'wan'
	list mode 'link'

config led
	option sysfs 'green:wifi5g'
	option trigger 'netdev'
	option dev 'br-lan.4'
	list mode 'tx'
	list mode 'rx'
	option name 'homeoffice act'

config led
	option sysfs 'green:wifi2g'
	option trigger 'netdev'
	option dev 'br-lan.10'
	list mode 'tx'
	list mode 'rx'
	option name 'lan act'

config led
	option name 'power'
	option sysfs 'green:power'
	option trigger 'heartbeat'

root@serenity-switch /root # uci export network
package network

config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fd30:6752:71b4::/48'
	option packet_steering '1'

config device
	option name 'br-lan'
	option type 'bridge'
	option ipv6 '0'
	list ports 'lan1'
	list ports 'lan2'
	list ports 'lan3'
	list ports 'lan4'
	list ports 'wan'

config interface 'lan'
	option device 'br-lan.10'
	option proto 'dhcp'

config interface 'guest'
	option proto 'none'
	option device 'br-lan.3'
	option delegate '0'

config interface 'homeoffice'
	option proto 'none'
	option device 'br-lan.4'
	option delegate '0'

config interface 'iot'
	option proto 'none'
	option device 'br-lan.5'
	option delegate '0'

config bridge-vlan
	option device 'br-lan'
	option vlan '10'
	list ports 'lan1:u*'
	list ports 'lan2:u*'
	list ports 'wan:t'

config bridge-vlan
	option device 'br-lan'
	option vlan '3'
	list ports 'wan:t'

config bridge-vlan
	option device 'br-lan'
	option vlan '4'
	list ports 'lan3:u*'
	list ports 'lan4:u*'
	list ports 'wan:t'

config bridge-vlan
	option device 'br-lan'
	option vlan '5'
	list ports 'wan:t'

config device
	option name 'br-lan.3'
	option type '8021q'
	option ifname 'br-lan'
	option vid '3'
	option ipv6 '0'

config device
	option name 'br-lan.4'
	option type '8021q'
	option ifname 'br-lan'
	option vid '4'
	option ipv6 '0'

config device
	option name 'br-lan.5'
	option type '8021q'
	option ifname 'br-lan'
	option vid '5'
	option ipv6 '0'

config device
	option name 'br-lan.10'
	option type '8021q'
	option ifname 'br-lan'
	option vid '10'
	option ipv6 '0'

root@serenity-switch /root # ls -l  /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*
lrwxrwxrwx    1 root     root            16 Sep  7 06:07 /etc/resolv.conf -> /tmp/resolv.conf
lrwxrwxrwx    1 root     root            35 Sep  7 06:07 /tmp/resolv.conf -> /tmp/resolv.conf.d/resolv.conf.auto
-rw-r--r--    1 root     root            49 Sep  7 06:07 /tmp/resolv.conf.d/resolv.conf.auto

/tmp/resolv.conf.d:
-rw-r--r--    1 root     root            49 Sep  7 06:07 resolv.conf.auto
root@serenity-switch /root # head -n -0 /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*
==> /etc/resolv.conf <==
# Interface lan
nameserver 10.0.4.250
search lan

==> /tmp/resolv.conf <==
# Interface lan
nameserver 10.0.4.250
search lan

==> /tmp/resolv.conf.d <==
head: /tmp/resolv.conf.d: I/O error

==> /tmp/resolv.conf.d/resolv.conf.auto <==
# Interface lan
nameserver 10.0.4.250
search lan
root@serenity-switch /root # nslookup 0.openwrt.pool.ntp.org
Server:		10.0.4.250
Address:	10.0.4.250:53

Non-authoritative answer:

Non-authoritative answer:
Name:	0.openwrt.pool.ntp.org
Address: 162.248.241.94
Name:	0.openwrt.pool.ntp.org
Address: 151.204.223.236
Name:	0.openwrt.pool.ntp.org
Address: 69.89.207.99
Name:	0.openwrt.pool.ntp.org
Address: 204.93.207.12

root@serenity-switch /root # cat /etc/rc.local
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

# these do not run APs
for i in firewall dnsmasq odhcpd wpad; do
  if [[ -f /etc/init.d/$i ]]; then
    if /etc/init.d/$i enabled; then
      /etc/init.d/$i stop
      /etc/init.d/$i disable
    fi
  fi
done

if [[ ! -f /root/.profile ]]; then
  echo "[[ -x /usr/bin/zsh ]] && exec zsh" > /root/.profile
fi

### .zshrc
if [[ ! -f /root/.zshrc ]]; then
cat <<EOF > /root/.zshrc
echo -e "\x1B]2;root@\$(uname -n)\x07";
bindkey -v

PS1='%F{green}%n%f@%m %/ # '
uptime
uname -a
PATH=\$PATH:\$HOME/bin

HISTFILE=/root/.zsh_history
HISTSIZE=10000
SAVEHIST=10000

setopt append_history
setopt hist_expire_dups_first
setopt hist_ignore_space
setopt inc_append_history
setopt share_history

bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[3~" delete-char

autoload -Uz up-line-or-beginning-search
autoload -Uz down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '\eOA' up-line-or-beginning-search
bindkey '\e[A' up-line-or-beginning-search
bindkey '\eOB' down-line-or-beginning-search
bindkey '\e[B' down-line-or-beginning-search

exit 0
root@serenity-switch /root # cat /root/update_date
cat: can't open '/root/update_date': No such file or directory
root@serenity-switch /root # /etc/init.d/sysntpd restart
root@serenity-switch /root # chmod 700 /root/update_date
chmod: /root/update_date: No such file or directory

I did not understand this part ... which package provides at

as I assume that when you restart your router you will not immediately be able to access resources on the internet

you can install the at command

opkg update; opkg install at

and edit your /etc/rc.local file

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

# these do not run APs
for i in firewall dnsmasq odhcpd wpad; do
  if [[ -f /etc/init.d/$i ]]; then
    if /etc/init.d/$i enabled; then
      /etc/init.d/$i stop
      /etc/init.d/$i disable
    fi
  fi
done

if [[ ! -f /root/.profile ]]; then
  echo "[[ -x /usr/bin/zsh ]] && exec zsh" > /root/.profile
fi

### .zshrc
if [[ ! -f /root/.zshrc ]]; then
cat <<EOF > /root/.zshrc
echo -e "\x1B]2;root@\$(uname -n)\x07";
bindkey -v

PS1='%F{green}%n%f@%m %/ # '
uptime
uname -a
PATH=\$PATH:\$HOME/bin

HISTFILE=/root/.zsh_history
HISTSIZE=10000
SAVEHIST=10000

setopt append_history
setopt hist_expire_dups_first
setopt hist_ignore_space
setopt inc_append_history
setopt share_history

bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[3~" delete-char

autoload -Uz up-line-or-beginning-search
autoload -Uz down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '\eOA' up-line-or-beginning-search
bindkey '\e[A' up-line-or-beginning-search
bindkey '\eOB' down-line-or-beginning-search
bindkey '\e[B' down-line-or-beginning-search

if [ -x /root/update_date ]; then
at -f /root/update_date now+2minutes 2> /dev/null 1> /dev/null
fi

exit 0

and add a script for updating the date

echo "/etc/init.d/sysntpd restart" >> /root/update_date; chmod 700 /root/update_date

you need to set both the gateway and dns addresses on your dumb AP.
assuming your main router handles DNS for your network, and that your dumb AP has a static IP that you have configured, you will have to set DNS specifically.

go to lan interface config.
on general settings tab, make sure the gateway is set to your main router IP .
on the advanced tab: make sure 'custom dns' is set to your main router IP if it has not picked it up automatically (which it won't with static IP)

1 Like

Original poster has it on dhcp.
But maybe indeed it can help if you set it to static, somehthing like this in /etc/config/network

config interface 'lan'
         option proto 'static'
         option device 'br-lan.10'
         option ipaddr '192.168.xxx.yyy'
         option netmask '255.255.255.0'
         option gateway '192.168.xxx.zzz'
         list dns '192.168.xxx.zzz'

you can also fill in something like 1.0.0.1 in list dns

I am not seeing a space for those... here is general followed by advanced:


change protocol to static then it will show up

I want to keep it as dynamic.

That is what I am not understanding. As it is configured, it works if sysntpd is manually triggered, so the DNS is getting discovered OK. Perhaps there is a race condition on boot or something that is starting sysntpd before that is setup?

EDIT: appending this to /etc/rc.local causes it to boot and have the correct time setup.

sleep 2s ; /etc/init.d/sysntpd restart

probably the ntp runs before it has a DHCP reply causing the fail. So indeed if you delay it then it likely works.

@ncompact - unless I am not understanding the purpose of the script you have provided, the vast majority has nothing to do with updating the time/date... I wouldn't recommend that anyone use this script, as it actually could cause more complications.

1 Like

to set the dns server manually, uncheck 'use DNS serverss advertized by peer'

regarding static vs dynamic -you have stated that you have wanted to stay as dynamic IP. with the default dynamic configuration, what are your dumb AP interface settings showing for DNS?

from the CLI, can you ping and resolve pool.openwrt.ntp.org? it was not clear from your posts.

I simply reported the script used and posted by the user,

I added a command that the user already said worked...

Maybe I expressed myself badly in my first post,
in which I had already put what the user would have to do to execute a command at system startup, after the network had started to work (2 minutes seemed enough to me).

cat /etc/rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

if [ -x /root/update_date ]; then
at -f /root/update_date now+2minutes 2> /dev/null 1> /dev/null
fi

exit 0

make script

echo "/etc/init.d/sysntpd restart" >> /root/update_date; chmod 700 /root/update_date

Yeah... that's fine. But most of the script -- all of the zshrc history stuff, disabling dnsmasq, firewall, etc... those don't apply here and shouldn't be added to rc.d

1 Like

That was already in the OP's rc.local, @ncompact was just quoting it

ah...ok. My mistake. Sorry about that @ncompact .

1 Like