Discussion:
[Dnsmasq-discuss] IP range with 0.0.0.0 netmask?
Andrea Galvani
2013-10-28 10:57:42 UTC
Permalink
Hello everyone.

I'm working on a particular network architecture which allows a host to
have any address inside of a network (that is, not only private
addresses!). The host is not directly reachable, and every connection
with the host is managed by the router above the network with an ad-hoc
protocol, which is not the matter here.

Since every host has a fixed IP, I'm using dnsmasq for storing static
leases for every host in the network.
For now I've been using only 10.0.0.0/8 addresses, but my idea is to
start using really "any" address possible (for example: 1.2.3.121).

So, apart from the static leases, I configured dnsmasq like this:

dhcp-range=wlan0,1.0.0.1,255.255.255.254,0.0.0.0,1h

Every host should obtain his static IP, without any restriction (even
outside of the 10.0.0.0/8 range).
The range seems to be ok as dnsmasq boots:

dnsmasq-dhcp[6180]: DHCP, IP range 1.0.0.1 -- 255.255.255.254, lease time 1h

But as soon as I connect a host (which should obtain 1.2.3.121) I get
this error as a result:

dnsmasq-dhcp[6180]: no address range available for DHCP request via wlan0

Is the range not accepted by dnsmasq?
Is it really possible to configure dnsmasq in order to provide "any"
address?
Are there some constraints (for example, on the netmask) which I'm missing?
If so, which is the biggest address pool that is possible to configure?

Thanks for the attention.

Andrea
Simon Kelley
2013-10-30 12:44:41 UTC
Permalink
Post by Andrea Galvani
Hello everyone.
I'm working on a particular network architecture which allows a host to
have any address inside of a network (that is, not only private
addresses!). The host is not directly reachable, and every connection
with the host is managed by the router above the network with an ad-hoc
protocol, which is not the matter here.
Since every host has a fixed IP, I'm using dnsmasq for storing static
leases for every host in the network.
For now I've been using only 10.0.0.0/8 addresses, but my idea is to
start using really "any" address possible (for example: 1.2.3.121).
dhcp-range=wlan0,1.0.0.1,255.255.255.254,0.0.0.0,1h
Every host should obtain his static IP, without any restriction (even
outside of the 10.0.0.0/8 range).
dnsmasq-dhcp[6180]: DHCP, IP range 1.0.0.1 -- 255.255.255.254, lease time 1h
But as soon as I connect a host (which should obtain 1.2.3.121) I get
dnsmasq-dhcp[6180]: no address range available for DHCP request via wlan0
Is the range not accepted by dnsmasq?
Is it really possible to configure dnsmasq in order to provide "any"
address?
Are there some constraints (for example, on the netmask) which I'm missing?
If so, which is the biggest address pool that is possible to configure?
The reason it's behaving like that is that for a dhcp-range to be valid,
the netmask has to equal the netmask of the interface where the DHCP
request arrived. I think it's unlikely that you have 0.0.0.0 as the
netmask, and if you did, it would break routing anyway. That explains
the problem: I don't think that there is a solution.


Cheers,
Simon
Andrea Galvani
2013-10-31 19:46:36 UTC
Permalink
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.
Brad Morgan
2013-10-31 21:42:14 UTC
Permalink
Post by Andrea Galvani
If I understood correctly, the IP I'm providing statically MUST be
contained inside the range I assign to the
Post by Andrea Galvani
interface, that's why for now I use a 10.0.0.0 /8. I would like to use a
/0.

I would think that 2*24 addresses (/8) would be enough for whatever you are
doing. Allowing "any" IP (meaning IPs out of the public address space) would
run the risk of making the "real" public IP unreachable.
Simon Kelley
2013-11-01 09:56:08 UTC
Permalink
Post by Andrea Galvani
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.
* 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)
dhcp-range=wlan0,10.0.0.1,10.255.255.254,255.0.0.0,1h
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

Loading...