Hello there,
I restarted my D-Link DIR-882 A1 router (OpenWrt 23.05.5 r24106-10cc5fcd00) because my internet was not working anymore. Afterwards, most of my lan devices lost their static IPs (e.g 192.168.1.185 or 192.168.1.174) and consecutive ones where allocated starting 192.168.1.101. I looked in the logs and saw "no address range available for DHCP request via br-lan". However, the static addresses 192.168.1.221 and 192.168.1.215 are still valid and working.
I would attach the 2 logs, but I did not figure yet how to do it.
Thank you.
I assume you mean DHCP reservations? Static IPs would be set on the hosts themselves and not subject to change due to events on the router.
Consecutive addressing means that devices not given a specific DHCP reservation cannot be assumed to maintain the same IP address across time and especially reboots. While non-sequential address allocation does not guarantee the same addresses will be issued consistently to a given host, it is much less likely to change because the DHCP server uses a hash of the MAC address to decide on an address to issue, rather than just 'the next sequential address.'
Let's start by looking at your configs:
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:
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/dhcp
Yes, I meant a DHCP reservation. I thought this is assigned by the router to a new device in the network. I assigned them infinite lease time hoping that if I have to restart the router, they keep the same DHCP reservation? Or maybe this is not the way it works? Sorry, my knowledge level is more "beginner" than "expert"
{
"kernel": "5.15.167",
"hostname": "OpenWrt",
"system": "MediaTek MT7621 ver:1 eco:3",
"model": "D-Link DIR-882 A1",
"board_name": "dlink,dir-882-a1",
"rootfs_type": "squashfs",
"release": {
"distribution": "OpenWrt",
"version": "23.05.5",
"revision": "r24106-10cc5fcd00",
"target": "ramips/mt7621",
"description": "OpenWrt 23.05.5 r24106-10cc5fcd00"
}
}
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 'XXXX:XXXX:XXXX::/48'
option packet_steering '1'
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
list ports 'lan4'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'wan'
option device 'wan'
option proto 'dhcp'
config interface 'wan6'
option device 'wan'
option proto 'dhcpv6'
config device
option type 'bridge'
option name 'br-guest'
option bridge_empty '1'
config interface 'OpenWrt_guest'
option proto 'static'
option device 'br-guest'
option ipaddr '192.168.2.1'
option netmask '255.255.255.0'
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 cachesize '1000'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
option localservice '1'
option ednspacket_max '1232'
config dhcp 'lan'
option interface 'lan'
option start '100'
option limit '150'
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'
config host
option name 'Number1'
option ip '192.168.1.202'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number2'
option ip '192.168.1.221'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number3'
option ip '192.168.1.222'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number4'
option ip '192.168.1.185'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number5'
option ip '192.168.1.174'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number6'
option ip '192.168.1.236'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number7'
option ip '192.168.1.130'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number8'
option ip '192.168.1.239'
option mac 'XXXXXXXXXXXX'
option leasetime 'infinite'
config host
option name 'Number9'
option ip '192.168.1.215'
option mac 'XXXXXXXXXXXX'
option leasetime '12h'
config host
option ip '192.168.1.228'
option mac 'XXXXXXXXXXXX'
option name 'Number10'
option leasetime 'infinite'
config domain
option name 'My_phone'
option ip '192.168.1.112'
config dhcp 'OpenWrt_guest'
option interface 'OpenWrt_guest'
option start '100'
option limit '150'
option leasetime '12h'
Remove the lease time from the DHCP reservation and setting the MAC as a list item, like this:
config host
option name 'Number1'
option ip '192.168.1.202'
list mac 'XXXXXXXXXXXX'
Then restart the router and test again.
Not sure if this can be done in the Web UI or SSH?
I tried to open the file with nano /etc/config/dhcp but I get nano: not found, probably not installed?
nano is not preinstalled, but vi is. You can always install the nano editor (opkg update; opkg install nano
) if you prefer to use that.
I installed nano (thank you for the tip) as I like keeping it simple.
I did what you advised me, also I deleted from DHCP and DNS all static leases.
I rebooted the router a few times and I noticed that each device now is keeping its DHCP reservation, I'm happy with that.
I had a look in the logs, I don't understand too many things from it and I would like to know if it's something that can cause problems sooner or later:
Sat Dec 7 20:45:37 2024 kern.info kernel: [ 2.081070] printk: console [ttyS0] enabled
Sat Dec 7 20:45:37 2024 kern.info kernel: [ 2.097588] printk: bootconsole [early0] disabled
Sat Dec 7 20:45:37 2024 kern.info kernel: [ 2.120093] spi-mt7621 1e000b00.spi: sys_freq: 220000000
Sat Dec 7 20:45:37 2024 kern.info kernel: [ 2.132056] spi-nor spi0.0: w25q128 (16384 Kbytes)
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.141767] 4 fixed-partitions partitions found on MTD device spi0.0
Sat Dec 7 20:45:37 2024 kern.err kernel: [ 2.154482] OF: Bad cell count for /palmbus@1e000000/spi@b00/flash@0/partitions
Sat Dec 7 20:45:37 2024 kern.err kernel: [ 2.169080] OF: Bad cell count for /palmbus@1e000000/spi@b00/flash@0/partitions
Sat Dec 7 20:45:37 2024 kern.err kernel: [ 2.184313] OF: Bad cell count for /palmbus@1e000000/spi@b00/flash@0/partitions
Sat Dec 7 20:45:37 2024 kern.err kernel: [ 2.198975] OF: Bad cell count for /palmbus@1e000000/spi@b00/flash@0/partitions
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.213881] Creating 4 MTD partitions on "spi0.0":
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.223471] 0x000000000000-0x000000030000 : "u-boot"
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.234651] 0x000000030000-0x000000040000 : "u-boot-env"
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.246437] 0x000000040000-0x000000060000 : "factory"
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.257758] 0x000000060000-0x000001000000 : "firmware"
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.269356] 2 uimage-fw partitions found on MTD device firmware
Sat Dec 7 20:45:37 2024 kern.notice kernel: [ 2.281190] Creating 2 MTD partitions on "firmware":
Sat Dec 7 20:45:49 2024 user.notice dnsmasq: found already running DHCP-server on interface 'br-lan' refusing to start, use 'option force 1' to override
Sat Dec 7 20:45:50 2024 kern.info kernel: [ 24.463242] br-lan: port 6(phy0-ap0) entered blocking state
Sat Dec 7 20:45:50 2024 kern.info kernel: [ 24.474427] br-lan: port 6(phy0-ap0) entered disabled state
Sat Dec 7 20:45:50 2024 kern.info kernel: [ 24.486117] device phy0-ap0 entered promiscuous mode
Sat Dec 7 20:47:28 2024 daemon.info dnsmasq[1]: read /etc/hosts - 12 names
Sat Dec 7 20:47:28 2024 daemon.info dnsmasq[1]: read /tmp/hosts/dhcp.cfg01411c - 4 names
Sat Dec 7 20:47:28 2024 daemon.info dnsmasq[1]: read /tmp/hosts/odhcpd - 0 names
Sat Dec 7 20:47:28 2024 daemon.info dnsmasq-dhcp[1]: read /etc/ethers - 0 addresses
Sat Dec 7 20:47:29 2024 daemon.info dnsmasq[1]: read /etc/hosts - 12 names
Sat Dec 7 20:47:29 2024 daemon.info dnsmasq[1]: read /tmp/hosts/dhcp.cfg01411c - 4 names
Sat Dec 7 20:47:29 2024 daemon.info dnsmasq[1]: read /tmp/hosts/odhcpd - 2 names
Sat Dec 7 20:47:29 2024 daemon.info dnsmasq-dhcp[1]: read /etc/ethers - 0 addresses
Sat Dec 7 20:47:30 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:30 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:30 2024 daemon.info hostapd: phy1-ap0: STA XX:XX:XX:XX:XX:XX IEEE 802.11: authenticated
Sat Dec 7 20:47:30 2024 daemon.info hostapd: phy1-ap0: STA XX:XX:XX:XX:XX:XX IEEE 802.11: associated (aid 3)
Sat Dec 7 20:47:30 2024 daemon.notice hostapd: phy1-ap0: AP-STA-CONNECTED XX:XX:XX:XX:XX:XX auth_alg=open
Sat Dec 7 20:47:30 2024 daemon.info hostapd: phy1-ap0: STA XX:XX:XX:XX:XX:XX WPA: pairwise key handshake completed (RSN)
Sat Dec 7 20:47:30 2024 daemon.notice hostapd: phy1-ap0: EAPOL-4WAY-HS-COMPLETED XX:XX:XX:XX:XX:XX
Sat Dec 7 20:47:31 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:31 2024 daemon.warn odhcpd[1556]: No default route present, overriding ra_lifetime!
Sat Dec 7 20:47:33 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:36 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:39 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:42 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:45 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:48 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:47:51 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:14 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:15 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:18 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:21 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:24 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:27 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:30 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:33 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:36 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:48:39 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:02 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:03 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:06 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:09 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:12 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:15 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:18 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:21 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:24 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:27 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:50 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:51 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:54 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
Sat Dec 7 20:49:57 2024 daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
I think you have to limit the pool size and use a range for static assign which are out of scope of the dynamic pool.
The log complains it has no space to use to assign dynamic clients.
Thank you for your quick reply.
I would appreciate a bit of guidance on how to address this as I have no clue how to do it
Ok let me do an example...
Lets say we split our 192.168.1.0/24
into some junks...
32 bit - 24 bit = 8 bit = 256
addresses in total.
Lets say we want "3 blocks"... One for the router and other special devices/services; one for dynamic clients, and one for the static one.
Which one is larger? The dynamic or the static one? Let's say the dynamic group is larger...
(A /26
is a forth (1/4
) of a /24
because 2 bit = 4
... and because we can not device by 3
we device by 4
...)
$ ipcalc 192.168.1.0/24 26
Address: 192.168.1.0 11000000.10101000.00000001. 00000000
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000
HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001
HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110
Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111
Hosts/Net: 254 Class C, Private Internet
Subnets after transition from /24 to /26
Netmask: 255.255.255.192 = 26 11111111.11111111.11111111.11 000000
Wildcard: 0.0.0.63 00000000.00000000.00000000.00 111111
1.
Network: 192.168.1.0/26 11000000.10101000.00000001.00 000000
HostMin: 192.168.1.1 11000000.10101000.00000001.00 000001
HostMax: 192.168.1.62 11000000.10101000.00000001.00 111110
Broadcast: 192.168.1.63 11000000.10101000.00000001.00 111111
Hosts/Net: 62 Class C, Private Internet
2.
Network: 192.168.1.64/26 11000000.10101000.00000001.01 000000
HostMin: 192.168.1.65 11000000.10101000.00000001.01 000001
HostMax: 192.168.1.126 11000000.10101000.00000001.01 111110
Broadcast: 192.168.1.127 11000000.10101000.00000001.01 111111
Hosts/Net: 62 Class C, Private Internet
3.
Network: 192.168.1.128/26 11000000.10101000.00000001.10 000000
HostMin: 192.168.1.129 11000000.10101000.00000001.10 000001
HostMax: 192.168.1.190 11000000.10101000.00000001.10 111110
Broadcast: 192.168.1.191 11000000.10101000.00000001.10 111111
Hosts/Net: 62 Class C, Private Internet
4.
Network: 192.168.1.192/26 11000000.10101000.00000001.11 000000
HostMin: 192.168.1.193 11000000.10101000.00000001.11 000001
HostMax: 192.168.1.254 11000000.10101000.00000001.11 111110
Broadcast: 192.168.1.255 11000000.10101000.00000001.11 111111
Hosts/Net: 62 Class C, Private Internet
Subnets: 4
Hosts: 248
The last two /26
can be aggregated into one /25
, which gives us:
192.168.1.0/26
192.168.1.64/26
192.168.1.128/25
Please do the lookup of "start" and "end" address for each block by yourself.
In case of dnsmasq
, the software which does DHCP on OpenWrt, this config stanza:
config dhcp 'lan'
option interface 'lan'
option start '100'
option limit '150'
...
reads as: Start at address "100" and end on "250".
So back to my example, you could say
config dhcp 'lan'
option interface 'lan'
option start '129'
option limit '125'
To assign dynamic clients from 192.168.1.129
up to 192.168.1.254
.
Edit: PS: And yes of course.... then you have to move all your static assignments into this block/range of addresses:
2.
Network: 192.168.1.64/26 11000000.10101000.00000001.01 000000
HostMin: 192.168.1.65 11000000.10101000.00000001.01 000001
HostMax: 192.168.1.126 11000000.10101000.00000001.01 111110
Broadcast: 192.168.1.127 11000000.10101000.00000001.01 111111
Hosts/Net: 62 Class C, Private Internet
Wow, quite overwhelming for me and very technical.
I looked around around if there could be other reasons for messages like
daemon.warn dnsmasq-dhcp[1]: no address range available for DHCP request via br-lan
and I found out that in the network might be a second device acting like a DHCP server. And it was, an access point! I changed its DHCP setting from auto to disabled and that message stopped appearing!