Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#477 closed defect (invalid)

dnsmasq init script gives out wrong IP address range

Reported by: oliverklozoff@… Owned by: developers
Priority: normal Milestone: 0.9/rc6
Component: packages Version:
Keywords: dnsmasq dhcp Cc:


In RC5 (White Russian), the init script for dnsmasq -- /etc/init.d/S50dnsmasq -- does this:

  ipaddr=$(nvram get ${iface}_ipaddr)
  netmask=$(nvram get ${iface}_netmask)
  start=$(nvram get dhcp_start)
> num=$(nvram get dhcp_num)
> num=$((start+${num:-150}))
> eval $(ipcalc $ipaddr $netmask $start $num)

Note the > lines. Let's consider this bit of configuration:


This should give out addresses from to 192.168.253. However, here's what happens:

  1. At the first >, num is set to '53'.
  2. At the second >, num is added to start, and thus set to '253'.
  3. At the third >, the resulting 'num' value is passed to ipcalc as the final argument.

The problem is that, this tries to assign 253 IP consecutive IP addresses. So instead of issuing IPs in the range, it issues

The proper fix would be to remove the line marked by the second >.

Attachments (0)

Change History (2)

comment:1 Changed 12 years ago by nico

  • Keywords changed from dnsmasq, dhcp to dnsmasq dhcp
  • Milestone set to 1.0-rc6
  • Resolution set to invalid
  • Status changed from new to closed

Already fixed by changeset:3525

comment:2 Changed 12 years ago by dsouth@…

A better fix is to just modify the second $num line:

$ diff S50dnsmasq.old
< num=$((start+${num:-150}))


This preserves the defaults (dns from 100-150) but lets the nvram variables override them correctly. Unless you're going to force setting the dns_start and dns_num on fresh installs

Add Comment

Modify Ticket

as closed .
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.