List of connected devices

I know there are threads already discussing this, but I am searching for a smarter solution.

I read [SOLVED] List ethernet devices/clients - #10 by guidosarducci and See all connected devices in Luci

Often the result of the recommended commands is empty because of a bug in dnsmasq.

I tried "cat /tmp/dhcp.leases". This lists only devices with dhcp and shows devices which are outside the pool. Ok, the reason could be, because I changed the DHCP-server from FritzOS to Openwrt while phones were running. So the migration was the problem probably. Wonder why I got from openwrt-dhcp my old Fritzbox IPs which are outside of the DHCP-pool. Not a problem, I changed to static IPs as much as possible.

dhcp.leases is empty after a reboot, which I don't understand. The DHCP-device, an internet radio is running.

After hours I see devices with arp, which don't exist, but there is the 1 DHCP-devices, which dhcp.leases doesn't show.

If I did not forget a device, there is only 1 DHCP-device, all others have static IPs.

arp-scan -I br-lan --localnet

is not reliable, doesn't show all devices after trying a few times and I am unable to sort the IP-addresses. At least "-n" doesn't help.

arp

(alone) shows more, but no idea how to sort the IP-address numerically. Ok, I could use "cut -f".

There is a package "static-neighbor-reports". How must I use it?

Should I install some packages?

I'm totally confused.

Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it 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
cat /etc/config/network
cat /etc/config/wireless
cat /etc/config/dhcp
cat /etc/config/firewall

if a client isn't directly connected to the rebooted openwrt device, it'll not notice there's been a reboot, hence lack of IP assignment from DHCP, in a worst case scenario, until the old DHCP lease expires.

3 Likes

I get that thx
I do not understand what they are expecting.

1 Like

np, answer was meant for OP, but I took the quote from your post ....

2 Likes

To be clear about this, there are several factors:

  1. the dhcp lease table is stored in RAM. That means when the device reboots, the table is lost.
  2. as @frollic mentioned...

This applies to devices connected to a downstream switch and/or other access points. Only client devices that are directly connected to the router would experience the ports going down and coming back up, while devices connected to any other switches and APs would not see any port/wifi bumps.

DHCP leases are only requested (by devices configured as DHCP clients) when the connection is established/re-established or for renewal based on the lease time (at 50% of the lease duration, or if unsuccessful at that time, it will try at 85%, and then 100% of the least-time).

So after a reboot, the lease table will remain empty or only partially populated until all client devices have had a reason to request/renew their leases.

1 Like

I think you should define what you mean by "connected": on the wifi world, it is very clear; but on the ethernet world, it is not as obvious.

1 Like

What bug in dnsmasq is that?

2 Likes
root@R7800:~# ubus call system board
{
	"kernel": "5.15.137",
	"hostname": "R7800",
	"system": "ARMv7 Processor rev 0 (v7l)",
	"model": "Netgear Nighthawk X4S R7800",
	"board_name": "netgear,r7800",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "23.05.2",
		"revision": "r23630-842932a63d",
		"target": "ipq806x/generic",
		"description": "OpenWrt 23.05.2 r23630-842932a63d"
	}
}

network

root@R7800:~# cat /etc/config/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 'fd0f:b7cb:66f2::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth1.1'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option ipaddr '192.168.178.13'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option gateway '192.168.178.1'
	list dns '192.168.178.1'

config interface 'wan'
	option device 'eth0.2'
	option proto 'dhcp'

config interface 'wan6'
	option device 'eth0.2'
	option proto 'dhcpv6'

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

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

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

wireless

root@R7800:~# cat /etc/config/wireless

config wifi-device 'radio0'
	option type 'mac80211'
	option path 'soc/1b500000.pci/pci0000:00/0000:00:00.0/0000:01:00.0'
	option channel '36'
	option band '5g'
	option htmode 'VHT40'
	option cell_density '0'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option ssid 'W...5-2'
	option encryption 'psk2'
	option key '...'

config wifi-iface 'wpa3_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option ssid 'W...5-3'
	option encryption 'sae'
	option key '...'

config wifi-device 'radio1'
	option type 'mac80211'
	option path 'soc/1b700000.pci/pci0001:00/0001:00:00.0/0001:01:00.0'
	option channel '11'
	option band '2g'
	option htmode 'HT20'
	option cell_density '0'

config wifi-iface 'default_radio1'
	option device 'radio1'
	option network 'lan'
	option mode 'ap'
	option wds '1'
	option ssid 'UP...S'
	option encryption 'sae'
	option key '...'

dhcp

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

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option nonegcache '0'
	option cachesize '1000'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	option nonwildcard '1'
	option localservice '1'
	option ednspacket_max '1232'
	option filter_aaaa '0'
	option filter_a '0'

config dhcp 'lan'
	option interface 'lan'
	option start '60'
	option limit '149'
	option leasetime '12h'
	option dhcpv4 'server'
	option dhcpv6 'server'
	option ra 'server'
	option ra_slaac '1'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

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'

firewall

root@R7800:~# cat /etc/config/firewall
config defaults
	option syn_flood	1
	option input		REJECT
	option output		ACCEPT
	option forward		REJECT
# Uncomment this line to disable ipv6 rules
#	option disable_ipv6	1

config zone
	option name		lan
	list   network		'lan'
	option input		ACCEPT
	option output		ACCEPT
	option forward		ACCEPT

config zone
	option name		wan
	list   network		'wan'
	list   network		'wan6'
	option input		REJECT
	option output		ACCEPT
	option forward		REJECT
	option masq		1
	option mtu_fix		1

config forwarding
	option src		lan
	option dest		wan

# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108
config rule
	option name		Allow-DHCP-Renew
	option src		wan
	option proto		udp
	option dest_port	68
	option target		ACCEPT
	option family		ipv4

# Allow IPv4 ping
config rule
	option name		Allow-Ping
	option src		wan
	option proto		icmp
	option icmp_type	echo-request
	option family		ipv4
	option target		ACCEPT

config rule
	option name		Allow-IGMP
	option src		wan
	option proto		igmp
	option family		ipv4
	option target		ACCEPT

# Allow DHCPv6 replies
# see https://github.com/openwrt/openwrt/issues/5066
config rule
	option name		Allow-DHCPv6
	option src		wan
	option proto		udp
	option dest_port	546
	option family		ipv6
	option target		ACCEPT

config rule
	option name		Allow-MLD
	option src		wan
	option proto		icmp
	option src_ip		fe80::/10
	list icmp_type		'130/0'
	list icmp_type		'131/0'
	list icmp_type		'132/0'
	list icmp_type		'143/0'
	option family		ipv6
	option target		ACCEPT

# Allow essential incoming IPv6 ICMP traffic
config rule
	option name		Allow-ICMPv6-Input
	option src		wan
	option proto	icmp
	list icmp_type		echo-request
	list icmp_type		echo-reply
	list icmp_type		destination-unreachable
	list icmp_type		packet-too-big
	list icmp_type		time-exceeded
	list icmp_type		bad-header
	list icmp_type		unknown-header-type
	list icmp_type		router-solicitation
	list icmp_type		neighbour-solicitation
	list icmp_type		router-advertisement
	list icmp_type		neighbour-advertisement
	option limit		1000/sec
	option family		ipv6
	option target		ACCEPT

# Allow essential forwarded IPv6 ICMP traffic
config rule
	option name		Allow-ICMPv6-Forward
	option src		wan
	option dest		*
	option proto		icmp
	list icmp_type		echo-request
	list icmp_type		echo-reply
	list icmp_type		destination-unreachable
	list icmp_type		packet-too-big
	list icmp_type		time-exceeded
	list icmp_type		bad-header
	list icmp_type		unknown-header-type
	option limit		1000/sec
	option family		ipv6
	option target		ACCEPT

config rule
	option name		Allow-IPSec-ESP
	option src		wan
	option dest		lan
	option proto		esp
	option target		ACCEPT

config rule
	option name		Allow-ISAKMP
	option src		wan
	option dest		lan
	option dest_port	500
	option proto		udp
	option target		ACCEPT


### EXAMPLE CONFIG SECTIONS
# do not allow a specific ip to access wan
#config rule
#	option src		lan
#	option src_ip	192.168.45.2
#	option dest		wan
#	option proto	tcp
#	option target	REJECT

# block a specific mac on wan
#config rule
#	option dest		wan
#	option src_mac	00:11:22:33:44:66
#	option target	REJECT

# block incoming ICMP traffic on a zone
#config rule
#	option src		lan
#	option proto	ICMP
#	option target	DROP

# port redirect port coming in on wan to lan
#config redirect
#	option src			wan
#	option src_dport	80
#	option dest			lan
#	option dest_ip		192.168.16.235
#	option dest_port	80
#	option proto		tcp

# port redirect of remapped ssh port (22001) on wan
#config redirect
#	option src		wan
#	option src_dport	22001
#	option dest		lan
#	option dest_port	22
#	option proto		tcp

### FULL CONFIG SECTIONS
#config rule
#	option src		lan
#	option src_ip	192.168.45.2
#	option src_mac	00:11:22:33:44:55
#	option src_port	80
#	option dest		wan
#	option dest_ip	194.25.2.129
#	option dest_port	120
#	option proto	tcp
#	option target	REJECT

#config redirect
#	option src		lan
#	option src_ip	192.168.45.2
#	option src_mac	00:11:22:33:44:55
#	option src_port		1024
#	option src_dport	80
#	option dest_ip	194.25.2.129
#	option dest_port	120
#	option proto	tcp

That is the case, but I tried to force a dhcp-query. I removed the power supply of the client for 1 minute.

In the meantime, I see a different IP

root@R7800:~# cat /tmp/dhcp.leases
1705274711 4c:...:cf 192.168.178.114 MD89295 *

I got very unsure if the device is configured with dhcp, so I started the network configuration and got a new IP address. Before it was 117,

config dhcp 'lan'
	option interface 'lan'
	option start '60'
	option limit '149'

Can I do something, that I get the 1st IP-address of the pool?

Yes.

1 Like

Which option is this in the config file?

sequential_ip

Feel free to refrence the Wiki: https://openwrt.org/docs/guide-user/base-system/dhcp#all_options

1 Like

Based on this, you appear to be running this device as a dumb ap.

Are you sure you want the dhcp server enabled here? In most cases, the main router has a dhcp server running. You can only have a single dhcp server on a network. two or more will cause problems as the one that responds will not be deterministic and they may clash in a few different ways. Furthermore, the dhcp server on a dumb AP will send the wrong sns and gateway unless set appropriately (it is indeed not correct in the config here).

Finally, dnsmasq will actually probe as it starts up to find out if another server is running on the network, and if one is found it will abort. This means the dhcp server on this device should not, in fact, be running. Thus your method of looking at the dhcp lease table would not be meaningful.

What is it that you are really trying to do here? Detect wireless devices directly connected to this ap? Thst can be done fairly easily, but as mentioned, it is more tricky if you are trying to get a topology of wired devices and/or wireless devices connected to other APs.

@linuxuser
Do you want a list of things on your network?
You can get all the things that are not asleep by doing:
ping -c 10 -I "br-lan" "ff02::1"

Then looking at the output of:
ip neigh
to work out the non-sleeping device's mac addresses.......

Note1: this ping will give many (DUP!) results. This is correct as each ping sent is a multicast that everything will reply to.

Note2: The ping command repeats 10 times to give "things" time to respond. You can play around with this if you wish.

This is am upstream WDS-router.

It is connected via Ethernet to the DSL-Fritzbox of the ISP. The Fritzbox runs Fritzos and cannot be modified. So I connect the Fritzbox via Ethernte cable with an Openwrt-router, which belongs to me and where I can do what I want.

The Fritzbox doesn't have DHCP enabled since a day and this openwrt router is the only router which has DHCP enabled.

Yes, but I am not sure if I configured all correctly.

This openwrt-router is more or less my main router.

I know

I don't understand why you call this router a dumb AP. As mentioned, it is a WDS upstream router. Everything seems to work, what I want. It is configured new with 23.05.2, so maybe I configured something wrong, but it works with the wireless APs (downstream).

Please tell me what I configured wrong / what I have to change.

How can I check this manually. I am pretty sure, there is no other DHCP-server running. I had this situation already with more than 1 dhcp-server and I fear dhcp was not disabled automatically. It was chaotic. Setup everything new.

Checking if it works, what I have configured. Looks to work, but this doesn't mean I have configured something wrong.

I want to detect all devices, which are listed by IP-address.

Yes, I would like to see all devices in my network. Arp doesn't show all devices sometimes. Nmap is better, but I don't like the presentation.

root@R7800:~# nmap -sP 192.168.178.0/24
Starting Nmap 7.93 ( https://nmap.org ) at 2024-01-14 17:36 UTC
Nmap scan report for 192.168.178.1
Host is up (0.0013s latency).
MAC Address: 74:...:F7 (AVM Audiovisuelles Marketing und Computersysteme GmbH)
Nmap scan report for 192.168.178.14
Host is up (0.0017s latency).
MAC Address: D4:...:74 (Zyxel Communications)

I would like to have 1 line like:

192.168.178.1	74:...:F7 (AVM Audiovisuelles Marketing und Computersysteme GmbH)
192.168.178.14	D4:...:74 (Zyxel Communications)

It should be better readable without overloading informations.

Am I invisible?

1 Like

Please verify that the Fritz DHCP server is indeed disabled.

Not in the current configuration. The OpenWrt device appear to be purely a dumb AP.

A dumb AP is just an access point. It does not do any routing (L3). This is the case in your situation (at least from all appearances) as your Fritz is doing the actual routing... since it looks like this device only has a lan-lan connection to the fritz (not using the OpenWrt WAN). This is just acting as an DHCP server and AP. Even if it is a WDS upstream device, it's still 'just' an access point insofar as it is not routing. WDS is simply a method of wirelessly connecting two or more APs wirelessly on the same L2 network.

You normally need to set the DHCP server such that option 3 advertises the correct gateway for your network. This appears to be the fritz at 192.168.178.1. Option 6 (DNS) can be used to point to the proper DNS server (which is also 192.168.178.1 per your lan config), but in this case it's probably not super critical insofar as OpenWrt is simply going to run its own DNS server and will send queries to the next specified upstream DNS (the fritz).

One way you can do this is to disable the OpenWrt DHCP server on the lan interface, and then force a device to renew its DHCP lease. If it fails to do so, that means that OpenWrt's DHCP is indeed the only one that was running. At that point, re-enable it.

(there are several other similar threads).

Yes, WAN is not used with openwrt and disabled with the Fritzbox too.

Please see the screenshots. The goal is to use the openwrt-device as DHCP-server.

Here you see the general setup of the Fritzbox.

Wan is used as LAN 5.

This is the only checkbox to disable DHCP I found with ipv4

Then there are ipv6 settings.

Default is DNS only

If I disable DHCPv6 there are these options. At the moment this is not set.

Are you connecting the Fritz!Box to an upstream internet connection? It appears so.

If you are, you've set it to use all 5 ports as LAN. These odd DHCP leases may be coming from the upstream, in that case.

I think you may need to change the WAN setting as you've already told the device that it will get an IP address from your internet provider. It looks to me like you've bridged the LAN and ISP sides together.

1 Like