Modify

Opened 3 years ago

Last modified 3 years ago

#18110 new defect

dnsmasq and ipcalc.sh range mismatch (off by one)

Reported by: anonymous Owned by: developers
Priority: normal Milestone:
Component: packages Version: Trunk
Keywords: dnsmasq, ipcalc.sh Cc:

Description

While testing. I noticed a mismatch between the IP range written in /tmp/etc/dnsmasq.conf (which ends at 10.177.31.253) and the one calculated by ipcalc.sh (which ends at 10.177.31.254)

root@OpenWrt:/etc/config# ipcalc.sh 10.177.0.1 19 129 8061
IP=10.177.0.1
NETMASK=255.255.224.0
BROADCAST=10.177.31.255
NETWORK=10.177.0.0
PREFIX=19
START=10.177.0.129
END=10.177.31.254

Yet when configuring dhcp

root@OpenWrt:/etc/config# cat dhcp
...
config dhcp 'lan5'
	option interface 'lan5'
	option start '129'
	option limit '8061'
	option leasetime '1h'
...

the resulting dnsmasq config file:

root@OpenWrt:/etc/config# cat /tmp/etc/dnsmasq.conf 
...
dhcp-range=lan5,10.177.0.129,10.177.31.253,255.255.224.0,1h

the IP range in /tmp/etc/dnsmasq.conf ends at 10.177.31.253 instead of 10.177.31.254 as calculated by ipcalc.sh

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by bittorf@…

the reason is line 413 in '/etc/init.d/dnsmasq':

[ "$limit" -gt 0 ] && limit=$((limit-1))

it was added in '5e1086da2dea492398407519d31310f5fb61880a':

dnsmasq: Fix parameter 'limit'

'limit' is actually the number of IP addresses to serve. See the use of ipcalc.sh.
For getting the expected number of IP addresses served, we have to decrement
limit by one.

hmm...

comment:2 follow-up: Changed 3 years ago by bittorf@…

some month later, there was a fix in '5d2766e7eb9b0db33917522d2cdcc291ddbdc3f9':

ipcalc.sh CIDR notation

[...]

The patch is based on #1260 [1], i just changed one line to calculate
the START end END ips right.
[...]

so maybe we can remove the limit-1?

comment:3 in reply to: ↑ 2 Changed 3 years ago by anonymous

Replying to bittorf@…:

so maybe we can remove the limit-1?

This seems to be the best solution.

comment:4 Changed 3 years ago by anonymous

bumping this old minor issue ...

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.