[Dnsmasq-discuss] IP range with 0.0.0.0 netmask?

Simon Kelley simon at thekelleys.org.uk
Fri Nov 1 09:56:08 GMT 2013


On 31/10/13 19:46, Andrea Galvani wrote:
> Hi Simon,
>
> thanks for your answer.
>
> You say that the IP address range should coincide with the netmask of
> the interface where I receive the DHCP Request (in my case, wlan0).
> Actually, my wlan0 is 10.1.1.0 /24, and I'm using dnsmasq to allocate
> users in /30 interfaces dynamically created for each one. These /30 are
> NOT part of the 10.1.1.0/24 prefix.
> Further more, my users have static IPs that belong to the range
> 10.0.0.0/8, so I've assigned that IP range to wlan0 on dnsmasq, and it
> works.
> For example:
> * wlan0 is working on 10.1.1.0 /24 (which can be seen as the "home"
> network)
> * a new user arrives, we know his MAC, which is assigned to a static IP
> (e.g. 10.1.2.121)
> * we allocate a /30 interface on that address (10.1.2.120 /30)
> * we use dnsmasq to send back to the user the static IP and all the
> parameters to work on the new interface (default gateway, netmask, etc)
>
> This actually works, with every address inside the 10.0.0.0 /8 range:
>
> dhcp-range=wlan0,10.0.0.1,10.255.255.254,255.0.0.0,1h
>
> For every user, a static IP + dhcp options:
>
> dhcp-host=XX:XX:XX:XX:XX:XX,set:alice,10.1.2.121
> dhcp-option=tag:alice,3,10.1.2.122
> dhcp-option=tag:alice,54,10.1.2.122
> dhcp-option=tag:alice,1,255.255.255.252
> dhcp-option=tag:alice,28,10.1.2.123
> dhcp-option=tag:alice,6,10.1.2.122
> dhcp-option=tag:alice,15,alice
>
> I'm using "special" software on the router, which allows to have ANY IP
> on the lan side (because these addresses are never directly exposed when
> routing through the Internet). Therefore, theoretically, I should tell
> the DHCP Server to be able to assign any address needed (even something
> like 1.2.3.4).
> If I understood correctly, the IP I'm providing statically MUST be
> contained inside the range I assign to the interface, that's why for now
> I use a 10.0.0.0 /8. I would like to use a /0.
>
> I wanted to understand if it's possible to do this with dnsmasq, or if
> it goes beyond the actual possibilities of a DHCP Server.
>

I'm not sure I follow exactly what you're doing, but I can give you the 
algorithm dnsmasq uses, if that helps.

When a DHCP request arrives, to start with all that's important is the 
interface on which it arrives.

The first stage is to take all the dhcp-range statements and filter 
them.  A valid dhcp-range for this filter is defined as one where
there is an address associated with the arrival interface which has the 
same netmask as the range, and the range start and end addresses both 
fall into the subnet calculated using the interface address and netmask.

Note that an interface may have more than one associated address/netmask.
Note also that a "static" range has start==end.

If there are no dhcp-ranges left after this filter you get the "No 
address range available" message.

Assuming there are still  the some dhcp-ranges left after the filter, 
one of them is used to allocate an IP address. If host has a configured 
static address, and that address is valid in one of the dhcp-ranges, 
then that range will be used and the static address allocated. If 
there's no static address configured, or it doesn't fall in any 
available range, then it's undefined which range is used, if there's 
more than one.


Cheers,

Simon



More information about the Dnsmasq-discuss mailing list