FYI, Re: How to set LAN subnet and DHCP assignment range

Yes there's an older thread on this topic, now closed. Its conclusion is no longer up to date and is misleading. As older threads are auto-closed and there's no way to add updates, I'm starting a new topic here - if maintainers feel offended, please refactor this appropriately.

So for the record for Google: apparently, DNSmasq is no longer the DHCP service running in OpenWRT (I'm running 19.07). The software used for DHCP and DHCPv6 (including posibbly relay services) is called odhcpd . Let me quote: "odhcpd uses a UCI configuration file in /etc/config/dhcp for configuration" . The DHCP assignment range is specified using two parameters: start and limit. The defaults are 100 and 150 respectively - probably meant to correspond with a typical "C-sized" LAN subnet (well, CIDR), yielding e.g. 192.168.x.100 to 192.168.x.249 (modulo a potential off-by-one error :wink: The start and limit parameters don't seem to have entries in the LuCi GUI - which in my case doesn't matter, as the compile-time defaults are reasonable for my use. Now I know that I can number my internal servers by the first 100 addresses in the subnet.

Not sure about how to select an interface where odhcpd should or should not run, not a problem I need to solve. It probably follows hints from other configuration elements, such as the outside vs. inside interface (generally speaking).

The is no error here. From 100 to 249 inclusive is 150 IP addresses.

I am not sure I am following. If you go to (or whatever your IP is) and edit the LAN interface, you will find that under DHCP Server > General Setup.


Is this true?
DHCP 4 is handled by dnsmasq in my system, with odhcpd handling DHCP 6.
I thought this was the default configuration too, as I haven't done anything special.


Oops. You're right! Apologies for the b.s. I got the wrong idea - probably because I couldn't find any references to DHCP in the config that's clearly related to DNSmasq.
Yes it does seem that DNSmasq still serves DHCP within ipv4, after all.

The only proof that I could find, but an important one, is the output of netstat -lnp:
udp 0 0* 1847/dnsmasq

Curiously, the advice from the odhcpd techref entry is pretty much true: the config is stored in /etc/config/dhcp , and the file does contain a range defined as "start 100, limit 150"

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

Which also answers the question "how to select, for which interfaces the DHCP server should cater".

Oh and yes there is one more hint that DNSmasq is still the DHCP server for IPv4:

config dnsmasq
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'

...and indeed the lease file does exist.

And @Hegabo is right, in Luci the range is configured via Network -> Interfaces -> Edit (a particular interface) -> the "DHCP server" tab

= apologies for the misinformation, and thanks for the precise response :slight_smile: