No internet connection from the router via ssh from time to time

You will have to install ntp-utils in order to access the utility ntpq.

root@R7800:~# ntpq -p
ntpq: read: Connection refused
root@R7800:~# ntpq -pn
ntpq: read: Connection refused

And now?

Are you running "real" ntp or the busybox version?

I don't know that the busybox version supports ntpq or other query operations. I don't see a listener on 123 on the OpenWrt box I checked.

http://doolittle.icarus.com/ntpclient/

Its functionality is a small subset of xntpd,

1 Like

I installed it via ssh on the R7800 and opkg.

root@R7800:~# opkg list-installed | grep -i ntp
ntp-utils - 4.2.8p11-1

ntpq> version
ntpq 4.2.8p11@1.3728-o Fri Aug 17 03:27:08 UTC 2018 (1)

root@R7800:~# ps w | grep -i ntp
 1157 root      1068 S<   /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.pool.ntp.org -p 2.o

I think you need to add the ip of the ntp ...

http://doc.ntp.org/4.1.0/ntpq.htm ->

root@R7800:~# ntpq <ip.of.the.ntp-server>

root@R7800:~# ntpq 192.168.178.55
ntpq> quit

root@R7800:~# ntpq
ntpq> ntpq 192.168.178.55
***Command `ntpq' unknown

ntpq> 192.168.178.55
***Command `192.168.178.55' unknown
ntpq>

1 Like

I thought openwrt installs a ntp server by default.

root@R7800:~# ntpq europe.pool.ntp.org

root@R7800:~# ntpq de.pool.ntp.org

root@R7800:~# ntpq 176.9.82.67
ntpq> 

Unfortunately this doesn't work too. Maybe you can give an example which works with your openwrt-router.

The goal is to see the difference between the local router and the ntp-server.

root@router:~# opkg install ntpdate
Installing ntpdate (4.2.8p11-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/packages/mips_24kc/packages/ntpdate_4.2.8p11-1_mips_24kc.ipk
Configuring ntpdate.
root@router:~# ntpdate de.pool.ntp.org

It installs the busybox version, as linked above. It is not feature complete, as also indicated above.

$ sudo ntpd --version
ntpd: unrecognized option: version
BusyBox v1.29.2 () 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 mins
	-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
root@router:~# opkg install ntpdate
Installing ntpdate (4.2.8p11-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/packages/mips_24kc/packages/ntpdate_4.2.8p11-1_mips_24kc.ipk
Configuring ntpdate.
root@router:~# ntpdate de.pool.ntp.org

Is it a risk to install this? May there be a conflict with the already installed packages?

Since it's not clear what you're trying to achieve, only you can answer if that goal is worth the very remote chance that you'll have some kind of incompatibility or misconfiguration. Any such problem would likely be able to be resolved by removing the package, or, at worst, resetting your device to defaults and reinstalling packages and configuration. There is always going to be unexpected failure modes when installing software on any system.

I was testing cronjobs and the time was wrong, so I thought the cronjobs didn't work. I was assuming that the router sets the time automatically from a ntpserver. I want to avoid this in the future. So I thought i want to test the difference between local time of the router and the correct time from the internet. But if this is not so easy, I forget it. I thought it is easy.

Time synchronization on OpenWrt is very straightforward.

Most all-in-one routers don't have a battery-backed RTC, so they have no notion of "now" at boot.

At boot, sysfixtime sets the time to a generally reasonable time by looking at the newest file in /etc/

Unless you've changed the configuration, sysntpd then starts

/usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.lede.pool.ntp.org -p 1.lede.pool.ntp.org -p 2.lede.pool.ntp.org -p 3.lede.pool.ntp.org

which takes over control of time.

If you've got problems with time and haven't mucked with the configuration, failure to resolve the NTP peer hostnames would be the most likely cause. "Bad" NTP references in your DHCP lease may be another problem.

Logging into your OpenWrt box and looking at the time in LuCI or with date and comparing with your desktop is one, very easy way.


Edit:

If you want full-on NTP and have sufficient space, the following should install and enable it for you:

opkg update
opkg install ntpd
/etc/init.d/sysntpd stop
/etc/init.d/sysntpd disable
/etc/init.d/ntpd enable
/etc/init.d/ntpd start

and ntpq should work

jeff@office:~$ ntpq
ntpq> pe
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+MTPBX.cytranet. 45.127.113.2     3 u   14   64   17   10.684    1.418   1.526
-lithium.constan 192.5.41.40      2 u   12   64   17   76.728    1.096   1.295
*45.32.199.189 ( 142.66.101.13    2 u   16   64   17   53.786    2.978   3.160
+den1.m-d.net    132.163.96.1     2 u   16   64   17   34.328    5.897   1.994
ntpq> rv
associd=0 status=0614 leap_none, sync_ntp, 1 event, freq_mode,
version="ntpd 4.2.8p12@1.3728-o Mon Nov 26 12:02:01 UTC 2018 (1)",
processor="mips", system="Linux/4.14.67", leap=00, stratum=3,
precision=-18, rootdelay=79.298, rootdisp=36.073, refid=45.32.199.189,
reftime=dfbc447a.dc2b6489  Wed, Dec 12 2018 18:37:46.860,
clock=dfbc448b.ed3e4019  Wed, Dec 12 2018 18:38:03.926, peer=35012, tc=6,
mintc=3, offset=-1.494592, frequency=0.000, sys_jitter=3.069965,
clk_jitter=3.099, clk_wander=0.000

Thanks a lot jeff, didn't know that this was so much effort, It works with R7800, but ....

root@R7800:~# ntpq
ntpq> pe
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*time.conova.com .GPS.            1 u   61   64   37   30.754   -0.672   0.497
+srv23.globale-g 131.188.3.221    2 u  100   64   36   48.956    0.411   1.895
-193.170.62.252  130.149.17.21    2 u   64   64   13   36.366   -0.404   0.636
+vpn.oe9hamnet.a .PPS.            1 u   27   64   77   44.723   -1.060   0.181

To check, if the wds-client works, I thought I compare:

root@R7800:~# nmap -sn 192.168.178.0/24 | grep -i "hosts up"
Nmap done: 256 IP addresses (11 hosts up) scanned in 10.75 seconds

But on the Archer C7, there is something wrong, probably DNS. The main difference on the server was that I have now "option dns", which was not found in the config files before, although I entered values.

root@R7800:~# grep -r "178\.1" /etc/
/etc/config/network:	option gateway '192.168.178.1'
/etc/config/network:	option dns '192.168.178.1'
grep: /etc/localtime: No such file or directory
grep: /etc/ppp/resolv.conf: No such file or directory

The question is, should I use "Use custom DNS servers" at http://192.168.178.59/cgi-bin/luci/admin/network/network/lan or DNS forwardings at http://192.168.178.59/cgi-bin/luci/admin/network/dhcp

root@archerc7v5:~# grep -r "178.1" /etc/
/etc/config/network: option dns '192.168.178.1'

Should I use the wds-master as gateway or the Fritzbox, which is gateway to the internet.

root@archerc7v5:~# grep -r "178\.55" /etc/
/etc/config/network:	option gateway '192.168.178.55'

Confused, before a reboot of the rooter it didn't work with the name, but with the ip:

root@archerc7v5:~# ping -c2 139.59.209.225
PING 139.59.209.225 (139.59.209.225): 56 data bytes
64 bytes from 139.59.209.225: seq=0 ttl=55 time=46.990 ms
64 bytes from 139.59.209.225: seq=1 ttl=55 time=46.598 ms
root@archerc7v5:~# ping -c2 openwrt.org
PING openwrt.org (139.59.209.225): 56 data bytes
64 bytes from 139.59.209.225: seq=0 ttl=55 time=46.720 ms
64 bytes from 139.59.209.225: seq=1 ttl=55 time=46.850 ms

Looks like, the client is ok now too:

root@archerc7v5:~# ntpq
ntpq> pe
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*80.64.136.37    131.130.250.250  2 u    4   64    1   34.750    9.553   0.219
+193.170.62.252  131.188.3.222    2 u    5   64    1   41.942   10.637   0.711
-185.9.19.142    89.109.251.21    2 u    5   64    1   81.807   -1.373   0.800
+extern4.nemox.n 80.92.126.65     3 u    6   64    1   43.313    8.850   0.505

Number of clients are the same:

root@archerc7v5:~# nmap -sn 192.168.178.0/24 | grep -i "hosts up"
Nmap done: 256 IP addresses (11 hosts up) scanned in 8.19 seconds

Could you please check the config files of the wds-client:

Network:

root@archerc7v5:~# cat /etc/config/network 

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

config globals 'globals'
	option ula_prefix '....-....-....::/48'

config interface 'lan'
	option type 'bridge'
	option ifname 'eth0.1'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.178.59'
	option stp '1'
	option dns '192.168.178.1'
	option gateway '192.168.178**.55**'

config interface 'wan'
	option ifname 'eth0.2'
	option proto 'none'

config interface 'wan6'
	option ifname 'eth0.2'
	option proto 'none'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '2 3 4 5 0t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '1 0t'

config interface 'wwan'
	option proto 'none'

DHCP:

root@archerc7v5:~# cat /etc/config/dhcp 

config dnsmasq
	option domainneeded '1'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.auto'
	option nonwildcard '1'
	option localservice '1'
	option authoritative '1'

config dhcp 'lan'
	option interface 'lan'
	option ignore '1'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

Both of your OpenWrt routers are LAN devices the same as your PCs or phones. All of your LAN devices should point to the Fritzbox as the gateway and DNS server.

I like to make the LAN a DHCP client so it automatically follows what the main router tells it. You can use hostnames or check the DHCP table in the main router to find the IP address of your OpenWrt devices. This of course requires a reliable connection to a main router DHCP server.

  • option hostname must be specified in the network config of the DHCP client network for it to be broadcast in a DHCP request and made available to the main router. The /etc/config/system hostname is not automatically used.

Thank you, not sure if I understood you right.

Do you mean, nothing at wds-client (.59) should point to the wds-master (.55)?

I have now:

root@archerc7v5:~# grep -r "178\.1" /etc/
/etc/config/network:	option dns '192.168.178.1'
/etc/config/network:	option gateway '192.168.178.1'
...

root@archerc7v5:~# grep -r "178\.55" /etc/
grep: /etc/localtime: No such file or directory
grep: /etc/ppp/resolv.conf: No such file or directory

From the results I see no difference, no idea if it is now faster.

Did I change it as you thought I should do? Thanks!

Maybe it should be mentioned at https://openwrt.org/docs/guide-user/network/wifi/atheroswds , that the confiugartion could be different, if the master-ap is not the gateway to the internet.

The WDS AP is working as a layer 2 bridge, it doesn't look at IP addresses on the way through. It takes traffic from wireless and sends it on to the cable to the Fritzbox. This is done at the MAC address level.

Thanks, I think I mark this thread as solved now, although there will be the next step with this configuration now. I want to include IoT, like a washing machine with a guest network.

Please discuss here: Guest network for washing machine, etc

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