OpenWrt Forum Archive

Topic: How to set a DHCP range in a /16 subnet?

The content of this topic has been archived on 27 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

OpenWRT serves DHCP request just fine in a /24 subnet.
In a bigger subnet there seems to be a missing option somewhere to more specifically specify how you want to set the dhcp range.

For instance, i have the network subnetmask:
255.255.0.0 (or /16) on the 10.0.*.* range.
I want DHCP to hand out IP's in the 10.0.3.* range.
I know, i change change the subnet to 255.255.255.0 which would "fix"this, but i don't want that. I want other devices in the other ranges. DD-WRT can do this just fine so i guess OpenWRT should be able to handle it as well (if one knows the options to set..).

So i either want to fill in a range like this:
3.0 - 3.150

Or with the full ip:
10.0.3.0 - 10.0.3.150

Does anyone know how i can get that done using dhcp?

Cheers,
Mark

a subnetmask 255.255.0.0 will go from 10.0.1.1 till 10.0.254.254, thas alot of IPs do you really want that ?

it seems you just want subnetmask 255.255.255.0, set the IP of your router to 10.0.3.1 and then the dhcp starting from 10.0.3.2 till 10.0.3.254 or wherever you want it to end.

Use start 768 and limit 150:
10.0.0.0 + (3 x 256) = 10.0.3.0
10.0.3.1 + 150 = 10.0.3.150

yoyellow wrote:

a subnetmask 255.255.0.0 will go from 10.0.1.1 till 10.0.254.254, thas alot of IPs do you really want that ?

it seems you just want subnetmask 255.255.255.0, set the IP of your router to 10.0.3.1 and then the dhcp starting from 10.0.3.2 till 10.0.3.254 or wherever you want it to end.

No, it doesn't seem like i want 255.255.255.0. I specifically said that i was not looking for that solution.
I might want to join multiple networks in this one big subnet where 10.0.1.* is one network, 10.0.2.* is another, etc...

I probably never going to use it or it's not going to work.. Fine. But i want to have the ability to do so on a network level hence the requirement to have ip's in a specific range from DHCP.

jow wrote:

Use start 768 and limit 150:
10.0.0.0 + (3 x 256) = 10.0.3.0
10.0.3.1 + 150 = 10.0.3.150

Oh wow! That smells like a nasty hack wink
But yeah, i did that now and it works just fine. Thank you very much for providing the solution.

** nice undocumented feature btw ;-) **

Its not a nasty hack but the way it is designed to work. The "start" parameter specifies the offset from the network address, most people think it is the "last octet" of the address but that is not the case. It is also documented: http://wiki.openwrt.org/doc/uci/dhcp#dhcp_pools

(start) Specifies the offset from the network address of the underlying interface to calculate the minimum address that may be leased to clients. It may be greater than 255 to span subnets.

Hey there.

Which document exactly lacks that information?

The regular "dhcp" wiki page I know about does state it clearly.
See http://wiki.openwrt.org/doc/uci/dhcp on the table described as "Below is a listing of legal options for dhcp sections".
There are both, "start" and "limit".

The LUCI input for DHCP configuration labeled with "Limit" has a question mark icon stating: "Lowest leased address as offset from the network address."

If you know about any documentation handling DHCP but missing either "start" or "limit", could you please link it to allow somebody to adjust it?

Btw: Currently you can still use "10.0.3.1" as "limit" value. Although *that* is not part of a documentation this setting currently works. Being a lacy reader, I just added that value to my LUCI panel, didn't think about it because it worked. Then read the wiki documentation about DHCP and remembered "wow, I just did it slightly different".

I don't know if this method is supposed to continue working but as of current stable BB it works.

As an additional note: Your description is kind of wrong when you talk about "I might want to join multiple networks in this one big subnet".
There are no sub-subnets within 10.0.0.0/16 if your subnet mask is /16. There is just one subnet.
You cannot have one computer at 10.0.0.1/16, a second one at 10.0.0.2/24 and a third one at 10.0.1.2/24 and expect them to interact properly. Either you have one 10.0.0.0/16 subnet and have all nodes within that /16 or you have multiple smaller ones. Then your router needs to have multiple interfaces, one for each small subnet. But configuring them "sub subnet within /16 and one overloard accessing the whole /16" isn't possible.
In one 10.0.0.0/16 you have the 10.0.0.0 as network and 10.0.255.255 as broadcast. The 10.0.0.255 as well as the 10.0.1.0 are just a regular node address.
In 10.0.0.0/24 you have the 10.0.0.0 as network as well but the 10.0.0.255 is not a regular node but the broadcast address.
So mixing different subnet masks for overlapping IP ranges leads to pretty unexpected errors.

Regards,
Stephan.

jow wrote:

Its not a nasty hack but the way it is designed to work. The "start" parameter specifies the offset from the network address, most people think it is the "last octet" of the address but that is not the case. It is also documented: http://wiki.openwrt.org/doc/uci/dhcp#dhcp_pools

(start) Specifies the offset from the network address of the underlying interface to calculate the minimum address that may be leased to clients. It may be greater than 255 to span subnets.

Ahh, so that's the intention. I was assuming (wrongly) that the offset was within the scope of the last octet. So an offset of max 256. I don't know why i read it that way, but i'm glad you pointed out the correct way smile

golialive wrote:

Hey there.

Which document exactly lacks that information?

The regular "dhcp" wiki page I know about does state it clearly.
See http://wiki.openwrt.org/doc/uci/dhcp on the table described as "Below is a listing of legal options for dhcp sections".
There are both, "start" and "limit".

The LUCI input for DHCP configuration labeled with "Limit" has a question mark icon stating: "Lowest leased address as offset from the network address."

If you know about any documentation handling DHCP but missing either "start" or "limit", could you please link it to allow somebody to adjust it?

Btw: Currently you can still use "10.0.3.1" as "limit" value. Although *that* is not part of a documentation this setting currently works. Being a lacy reader, I just added that value to my LUCI panel, didn't think about it because it worked. Then read the wiki documentation about DHCP and remembered "wow, I just did it slightly different".

I don't know if this method is supposed to continue working but as of current stable BB it works.

See above smile
My mistake.

golialive wrote:

As an additional note: Your description is kind of wrong when you talk about "I might want to join multiple networks in this one big subnet".
There are no sub-subnets within 10.0.0.0/16 if your subnet mask is /16. There is just one subnet.
You cannot have one computer at 10.0.0.1/16, a second one at 10.0.0.2/24 and a third one at 10.0.1.2/24 and expect them to interact properly. Either you have one 10.0.0.0/16 subnet and have all nodes within that /16 or you have multiple smaller ones. Then your router needs to have multiple interfaces, one for each small subnet. But configuring them "sub subnet within /16 and one overloard accessing the whole /16" isn't possible.
In one 10.0.0.0/16 you have the 10.0.0.0 as network and 10.0.255.255 as broadcast. The 10.0.0.255 as well as the 10.0.1.0 are just a regular node address.
In 10.0.0.0/24 you have the 10.0.0.0 as network as well but the 10.0.0.255 is not a regular node but the broadcast address.
So mixing different subnet masks for overlapping IP ranges leads to pretty unexpected errors.

Regards,
Stephan.

Hi Stephan,

My description isn't wrong, your interpretation of it is wrong since you're assuming things you just don't know. I meant exactly what i said, join multiple networks within the same subnet scope.
So:
Network 1: 10.0.1.* (subnetmask 255.255.0.0)
Network 2: 10.0.2.* (subnetmask 255.255.0.0)
etc...

I know it works because i've had that working for a couple of years with site-to-site networking via dd-wrt and vpn using a tap interface. Specifically NOT tun! I don't know why you assume that other networks might have a /24 subnet since i gave no hint of that. But lets not discuss that in this topic. It's not an issue at the moment and i don't even know if i'm going to set this up again (since it's very difficult to get right).

I just want to say thanks for this thread. It helped me configure a multiple /24 subnet spanning DHCP setup.
Yes, all information is already properly stated in the wiki. But this thread is really helpful, being a bit more verbose with the equations for calculating the DHCP range ;-)

(Last edited by pklaus on 22 Apr 2016, 18:50)

The discussion might have continued from here.