Modify

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:

Description

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)
  start=$((network+${start:-100}))
> 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:

lan_ipaddr=192.168.0.1
lan_netmask=255.255.240.0
dhcp_start=200
dhcp_num=53

This should give out addresses from 192.168.0.200 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 192.168.0.200-192.168.0.253, it issues 192.168.0.200-192.168.1.137.

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 S50dnsmasq.new
21c21
< num=$((start+${num:-150}))
---

num=$((${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

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


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

 
Note: See TracTickets for help on using tickets.