Dhcp doesn't work anymore when router IP is inside dhcp range

the router ip address is 192.168.13.13, netmask is 255.255.255.128.
dhcp configuration is set up to assign IPs from 1..126.
with this configuration logread shows error:

Sat Jul 22 09:02:46 2023 daemon.crit dnsmasq[1]: FAILED to start up
Sat Jul 22 09:02:51 2023 daemon.crit dnsmasq[1]: bad dhcp-range at line 32 of /var/etc/dnsmasq.conf.cfg01411c

inside the above mentioned file there is a line 32 with the following entry:

dhcp-range=set:lan,19,,255.255.255.128,2m

when dnsmasq is restarted it shows the message:

# service dnsmasq restart
udhcpc: started, v1.36.1
udhcpc: broadcasting discover
udhcpc: no lease, failing
ipaddr inside range

when router ip address is set to 192.168.13.126 and dhcp range from 1 to 125 then everything works. the line in /var/etc/dnsmasq.conf.cfg01411c looks like this:

dhcp-range=set:lan,192.168.13.1,192.168.13.125,255.255.255.128,2m

for years I was just saving backups of such configuration and was restoring it on new versions of openwrt. this has changed for 23.05. it doesn't work anymore.

what options are there for dhcp configuration except network reconfiguration? it is not a PITA for me. but as I encountered this issue I would like to learn about possibilities to workaround for dhcp server. can it accept a few ranges of addresses to assign from? is multiple dhcp server an option, each one with its own pool of addresses so that they would skip over the address assigned to the router?

since your router has the ip address 192.168.13.13 I would start the dhcp from the address 192.168.13.20 up to 192.168.13.126

dhcp-range=set:lan,192.168.13.20,192.168.13.125,255.255.255.128,2m
Address:   192.168.13.1          11000000.10101000.00001101.0 0000001
Netmask:   255.255.255.128 = 25  11111111.11111111.11111111.1 0000000
Wildcard:  0.0.0.127             00000000.00000000.00000000.0 1111111
=>
Network:   192.168.13.0/25       11000000.10101000.00001101.0 0000000 (Class C)
Broadcast: 192.168.13.127        11000000.10101000.00001101.0 1111111
HostMin:   192.168.13.1          11000000.10101000.00001101.0 0000001
HostMax:   192.168.13.126        11000000.10101000.00001101.0 1111110
Hosts/Net: 126                   (Private Internet)

edit the /etc/config/dhcp file and restart the service or router

config dhcp 'lan'
        option interface 'lan'
        option start '20'
        option limit '126'
        option leasetime '2m'
        option dhcpv4 'server'

2 minutes of lease is really the minimum unless the hosts of your network (PCs, printers, etc.) change so frequently,
I would increase it:

thank you! I can reconfigure the network as you suggests. I can leave it as it is now with router at .126. but I'm wondering why dhcp with this configuration worked for years and stopped for version 23.05. if I still wanted to keep full range 1..126 for dhcp (except 13 or whatever that is assigned to the router) -- what could be done in openwrt 23.05 to allow this? why did it stop working for version 23.05? was it a bug then and now it is fixed? or is it a bug now? :slight_smile:

"but as I encountered this issue I would like to learn about possibilities to workaround for dhcp server. can it accept a few ranges of addresses to assign from? is multiple dhcp server an option, each one with its own pool of addresses so that they would skip over the address assigned to the router?"

a client requests an ip address, the first dhcp server (hopefully the only one) replies.

if you need to have multiple dhcp servers my advice is VLANs

as regards skipping an ip address in the lease, I find it difficult usually the lease starts after the fixed or prefixed ip addresses on your network

1 Like

"full range 1..126 for dhcp (except 13 or whatever that is assigned to the router) "

I'm sorry I ignore this, are you sure that in the past it worked with an ip address present in the lease?

maybe you had a different netmask or your lease started differently.

Address:   192.168.13.1          11000000.10101000.00001101.0 0000001
Netmask:   255.255.255.128 = 25  11111111.11111111.11111111.1 0000000
Wildcard:  0.0.0.127             00000000.00000000.00000000.0 1111111
=>
Network:   192.168.13.0/25       11000000.10101000.00001101.0 0000000 (Class C)
Broadcast: 192.168.13.127        11000000.10101000.00001101.0 1111111
HostMin:   192.168.13.1          11000000.10101000.00001101.0 0000001
HostMax:   192.168.13.126        11000000.10101000.00001101.0 1111110
Hosts/Net: 126                   (Private Internet)

Address:   192.168.13.128        11000000.10101000.00001101.1 0000000
Netmask:   255.255.255.128 = 25  11111111.11111111.11111111.1 0000000
Wildcard:  0.0.0.127             00000000.00000000.00000000.0 1111111
=>
Network:   192.168.13.128/25     11000000.10101000.00001101.1 0000000 (Class C)
Broadcast: 192.168.13.255        11000000.10101000.00001101.1 1111111
HostMin:   192.168.13.129        11000000.10101000.00001101.1 0000001
HostMax:   192.168.13.254        11000000.10101000.00001101.1 1111110
Hosts/Net: 126                   (Private Internet)
2 Likes

I had two attempts for this. just backuped up the configuration from 22.03 and loaded into 23.05. it didn't work. backuped dhcp was:

config dhcp 'lan'
option interface 'lan'
option start '1'
option limit '63'
option leasetime '2m'
option dhcpv4 'server'
list ra_flags 'none'

and in network file:

config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.13.13'
option netmask '255.255.255.192'
option delegate '0'

so this working configuration was saved from 22.03 into 23.05 and failed.

then I started experimenting. I increased netmask to 255.255.255.128 and experimented with this. and here I am.

then I guess so much of a pre-existing bug in previous versions

Address:   192.168.13.1          11000000.10101000.00001101.00 000001
Netmask:   255.255.255.192 = 26  11111111.11111111.11111111.11 000000
Wildcard:  0.0.0.63              00000000.00000000.00000000.00 111111
=>
Network:   192.168.13.0/26       11000000.10101000.00001101.00 000000 (Class C)
Broadcast: 192.168.13.63         11000000.10101000.00001101.00 111111
HostMin:   192.168.13.1          11000000.10101000.00001101.00 000001
HostMax:   192.168.13.62         11000000.10101000.00001101.00 111110
Hosts/Net: 62                    (Private Internet)

i would expect a maximum lease for this network from 192.168.13.2 up to 192.168.13.62 with the server being 192.168.13.1

or a correct lease from 192.168.13.14 up to 192.168.13.62 with the server with ip address 192.168.13.13

if this is the fact then it is strange for me :slight_smile: skipping over statically assigned IP -- if I can rephrase it this way -- is just bread and butter for dhcp. there are some static entries in dhcp so that dhcp "knows" what ip are not assignable to any other host except the one stated in such entry. but hell, maybe you're right :slight_smile:

I hope so (just using common sense),
then of course people can do whatever they want including assign the same ip address to two machines and complain that sometimes something doesn't work.

you have a particular reason not to use a netmask /24 "255.255.255.0"

makes the situation clearer and more classic

everything you suggest is right. but my question was more technical even it showed my preferences. I can change preferences but the software would still remain buggy (if this is the case). I just noticed that particular configuration worked for years and stopped.

then you need to open a bug report

1 Like

I think they've already corrected it but I'm sorry I can't waste so much time looking for where and when they corrected it

ipaddr inside range

# service dnsmasq restart
udhcpc: started, v1.36.1
udhcpc: broadcasting discover
udhcpc: no lease, failing
ipaddr inside range

The "limit" option is not the end address, but the size of the DHCP pool.

1 plus 63 would already be 64, exceeding your netmask (that specifies 0-63 as the subnet).
Or if thinking "63 addresses starting from 1 including it", the range would still include the broadcast address .63 , so it would be similarly wrong.

Edit: our init script seems to properly calculate it, so "start 1, limit 63" would mean 1-63.

Note that the mentioned "start 20, limit 126" would actually mean 20-145, thus exceeding the subnet.

1 Like

Recent ipcalc.sh changes can cause issues with “bad” configs.

1 Like

please take a look at this:

I made a few tests. It looks like it doesn't matter if range is a bit narrower. router ip is inside such range
and this seems to break dhcp.

Why are you assigning a static IP to the router from within the range of addresses you want to be available for dynamic addressing?

for this case it is my love to 13.

Frankly I'm amazed it ever worked. I also think it would be unusual for someone to program a specific error message into DNSmasq for a 'bug'. We can probably safely assume that what you are seeing is intended behaviour and you should either change the router IP or the DHCP range.