How to set LAN subnet and DHCP assignment range

Dear Colleagues:

  1. I am planning an experiments on certain network behaviors that may be influenced by the IPv4 address range being used.

  2. Reading the OpenWrt Documentation, I find under "DHCP Pools",

https://openwrt.org/docs/guide-user/base-system/dhcp_configuration

a description:

100 is the offset from the network address, in the default configuration this would mean start leasing addresses from 192.168.1.100,

My reading of this is that the default starting network address is 192.168.1.0.

  1. In other parts of the same document, I see the use of the other two private netblocks 10.0.0.0 and 172.16.0.0 in examples. However, I can not find the instruction about how to specify either of them to be the default network address for a DHCP Pool. Please advise.

Thanks,

Let's not pursue that...

Yes, this is the default network used by default for LAN in OpenWrt.

In order to use numbers in that range for a DHCP lease, you must renumber your LAN to use one of those network numbers instead. This is called renumbering your Local Network.

See:

You renumber your LAN:

  • on the LuCI web GUI under Network > Interfaces > LAN; or
  • by editing LAN section in /etc/config/network

Hope this helps.

1 Like
# uci show | grep 192.168
network.lan.ipaddr='192.168.1.1'
2 Likes

Hi, lleachii:

  1. Appreciate your advice.

  2. " LuCI web GUI ":

Could you give me the URL to the description for this?

  1. How does the part of document describing this procedure relate to the what I have been reading in the main OpenWrt Documentation - User Guide where I picked up the question?

Thanks.

WARNING: I highly suggest just browsing to the router's homepage, instead.

I'll be honest:

  • I have no clue what you've been reading
  • I have no clue what you actually understand
  • It only loosely relates (as most Network Engineers would know)

You asked:

In order to do so, you must renumber your LAN. That simple.

  • If you do not understand, please read RFC2071. It clearly explains why.

Otherwise there is no further direct relation or correlation to what you appear to have been reading regarding DHCP.

1 Like

Hi, vgaetera:

Thanks for you response.

However, I am looking for documentation or "instruction about how to specify".

(A) Look at the UI
(B) https://openwrt.org/docs/guide-user/base-system/basic-networking

1 Like

Screenshot%20from%202018-10-09%2022-09-57

So from the command output above you can see private network address is specified in the only place which is LAN-network configuration.

1 Like

Hi, vgaetera:

If I understand properly, the question that I am asking is at a level that is deeper than the Documentation covers. It is probably described inline with the source code. I need to actually experiment with the OpenWrt code to find out.

Thanks

You so not configure the network segment in the DHCP pool, you configure the network segment in the LAN interface, then the start and length of the pool in the DHCP configuration.

1 Like

Hi, eduperez:

  1. I think that I am getting the idea.

  2. Since the DHCP pool specification only defines "offset" parameters, there will be only one active network segment on a LAN interface, correct?

Thanks

1 Like

I'd surmise to say...just experiment with the software. This is apparent if you're looking at the running machine.

1 Like

The DHCP server uses the first address in the subnet block, plus the configured "start" parameter, as the starting point. The first and last IPs in a subnet block are reserved for broadcast purposes and can't be used by a client. For a /24 block those would be the addresses that end in .0 and .255.

Note that unlike some other routers, OpenWrt / dnsmasq DHCP addresses are not assigned in numerical order as clients connect. They are based on hashing the client's MAC address so they land "randomly" somewhere within the assignable range. But they will always be in the assignable range.

2 Likes

This is not the actual reasoning why.

In order to use working IP addresses (i.e. that will route and forward), the DHCP system running on the network must issue addresses and configurations EXACTLY IDENTICAL to the configs of the running network itself. OpenWrt handles that by only configuring DHCP to use "offsets" (as you describe them).

Dynamic Host Configuration Protocol (DHCP) servers runs on most consumer-grade or end-client routers and Access Points. It is not required to run a network. In a case where a network does not use DHCP, it's called Static Addressing. Perhaps this helps on your confusion on DHCP network numbering and network Interface configurations relating to one another.

Aren't we mixing different concepts here? On one side there is the network interface, on the other side is the DHCP server, and in the middle there is UCI. I would first decide what do you need, in terms of functionality, and then how (if possible) to configure that using UCI.

You can have several network segments in the same interface, and you can configure that using UCI (see https://openwrt.org/docs/guide-user/network/network_interface_alias). Now, having a DHCP server on a multi-segment network interface (if you need it, you can always experiment using static IP addresses) is a bit trickier, and I do not think you can configure that using UCI; but that does not mean that it cannot be done, perhaps you will have to configure DNSMASQ manually, perhaps you will have to use another DHCPd.

1 Like

Hi, eduperez:

  1. Thank you for bring up the "Divide and Conquer" approach to keep this Q&A orderly.

  2. My basic question is whether the DHCP pool starting address may be specified (changed from the default)?

  3. If so, is there any documented procedure?

  4. Using UCI may be the way to do it. But, it opens up another set of topics of how to use it to accomplish the goal in Pt. 1).

  5. Several network segments in the same interface leading to some complications that you stated is something that I should avoid at this preliminary phase of the study.

  6. As to static address assignment, it may be related to eventual configuration of the environment that I may be set up. It can be treated as a special case of DHCP, so that we do not need to look at at this juncture.

  7. So, please guide me through the first three steps. We should put steps 4 & 5 aside for now.

Thanks,

Basic operations like points 1-3 are almost self-explanatory in the LuCI GUI. You really should just install OpenWrt on something and try it. Point 5 is usually handled by making DHCP reservations (which is supported by the GUI) instead of having a mix of static and dynamically assigned addresses on the same network.

Multiple networks on one interface is an advanced topic and usually there is a better way to do what you are trying to achieve without having multiple networks on one interface. The one exception is having a cable modem where the WAN obtains a public IP address from the cable system as a DHCP client, and also holds a private static IP to allow logging into the modem. In that case there is no DHCP server in the router for either use of the WAN port.

In general the more complete documentation assumes you're going to configure with the CLI. Searching the OpenWrt wiki will find pages like this one:
https://wiki.openwrt.org/doc/uci/dhcp

  1. The starting address for the DHCP pool is constructed from the IP address of the interface ("option ipaddr" at /etc/config/network) and the range defined for that interface ("option start" at /etc/config/dhcp).

  2. This is documented at https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#dhcp_pools.

2 Likes

Hi, mk24 and eduperez:

  1. Appreciate you instructions and explanations. Indeed, the first three steps should be fairly straightforward. I was just lost while trying to navigate through a set of unfamiliar documents and terminology.

  2. With the above understanding, I looked at some off-the-shelf routers. It seems from their GUI descriptions that some of them are pretty open about specifying the LAN address and DHCP parameters. I have not touched these for a long time. And, of course there was not a situation that I wanted to pay attention to them from this angle back then. I will try to decide one of them from the store to attempt changing the configuration parameters.

  3. Actually, now that you helped me to focus on these two sets of parameters, my experiment becomes really simple. That is, take one of the common working retail routers and set its LAN address to say 240.1.1.1 and pick two no-zero numbers (say 100 and 250) to set the starting and ending addresses of the DHCP pool. With all IoTs on this LAN set to DHCP client mode, can they PING one another (or equivalent operation) successfully? Based on what I learned from tests performed by other colleagues on a different thread, the IoTs need be Linux based PC, because Windows may not send the packet out.

Thanks,