I did not find answers, neither by searching this forum nor in the documentation, so I put my questions into this new topic here.
Is the DHCP server in OpenWRT able to serve DHCP clients only in /24 subnet (mask 255.255.255.0), or also for more DHCP clients in broader /23 subnet (mask 255.255.254.0)?
How many DHCP clients can have manually assigned IP according to their MAC address in OpenWRT?
...my Asus router running stock firmware supports only 64 dhcp clients in manual IP assignment, so I am looking for the possibility to increase that number - hopefully OpenWRT will solve it (?)
The DHCP server uses the lan's netmask to define the range, so if you set it to 255.255.0.0 (/16), then you'll get a /16 range served up. In LuCI, go to Network -> Interfaces -> LAN edit button, then on the General Settings tab your netmask defines this maximal range. Then go to the DHCP Server tab and you can subset that using the Start and Limit values.
To reserve IPs simply go to Network -> DHCP and DNS, and on the Static Leases tab you can add by-MAC reservations and give them IP addresses (both IPv4 and/or IPv6 may be reserved).
Yes, and that specific example implies a /23 netmask. However, which address in that range would the router use? I would suggest 0.2 to 1.254, with the router at 0.1. But ultimately your addressing scheme is up to you.
OpenWRT uses dnsmasq for its DHCP and DNS; if you want to know more about dnsmasq's capabilities, the man page at dnsmasq.org might be helpful.
Correct. As Dave says, if you're using a /23 all the addresses 0.1 through 1.254 are available for use on your LAN devices, but you need to reserve one for the router itself, which by convention is the 0.1 address (sometimes you'll see people grab the other end of the address space for the router IP, i.e., 1.254 on a /23, but that's relatively rare).
You can create as many reservations as there are available addresses, so for a /23, that would be 2**9 - "already used", where already used is the router IP and the broadcast 1.255, so 510.
My personal convention is to partition up the IP space for each "class" of devices. For example, all my routers are .1-.9, switches are at .10-.19, WAPs are .20-.29, IoT is .50-.99, servers are .200-up, and DHCP clients fall in the .100-.199 range. Everything outside .100-.199 is in my reservation table, with manually defined IP addresses.
Here are some of them on my main LAN, using a 10.1.1.0/24 space where the main router is at 10.1.1.1:
I was also on Asus based router firmware before moving to OpenWrt and this is another planet altogether, a much better one.
All the list entries limitations, caused by the limited amount of nvram to store settings on the Asus firmware, don't exist here, nor do a lot of other limitations, like /24's only.. And those are just relatively minor things that you'll notice when you land, but there's so much to discover, it doesn't end.
Thank you guys
...hopefully I will be on OpenWRT later today - I am full of expectations - with no such old Asus router limitations and up to date with security...
...yes, my IP space is divided into more "device type spaces" (PCs, NTBs, TV/STBs, IoT sensors, cameras, printers, etc) but I have been forced to stop using manual IP assignments on all devices due to the 64 clients Asus stock FW limitations.
Is there any possibility to import a list of manual IP assignments (MAC & IP list)? Probably I will see after my first experience with OpenWrt GUI...
Yup, but you'll need to access the router command line over ssh (use putty if your main workstation is Windows; ssh on MacOS, Linux or Unix, but that's for another thread).
You can use a couple of formats, but probably the most human-readable is the uci config file one (as opposed to uci's slightly more cryptic command format). If you have a list of host names, MACs and IPs, then you write a script to spit out bits that look like this, then either uci import them, or just manually paste them into the /etc/config/dhcp file.
Here's an example corresponding to my rtr01 (pretty imaginative names, eh?) from the image I pasted above.
config host
option name 'rtr01'
option dns '1'
option mac '50:C7:BF:Cx:xx:xx'
option ip '10.1.1.4'
option hostid '4'
option duid '0003000150c7bfcxxxxx'
$ cat dhcp_gen.uc
#!/usr/bin/utpl
{%
// Written in jow's ucode, which is installed by default on all versions
// of OpenWrt 22.03 and later. See https://ucode.mein.io/
// Table of whitespace separated host info (leading and trailing
// whitespace is stripped). If you wish to read this from a file,
// see the core 'render' function: hosts = render("the_file");
subnet = "192.168.2";
hosts = "
host1 104 xx:yy:zz:11:22:33
host2 106 yx:zy:xz:11:22:33
dbmaster 196 aa:bb:cc:11:22:33
";
for (line in split(trim(hosts), "\n")):
parts = split(trim(line), /[ \t]+/);
name = parts[0], id = parts[1], mac = parts[2];
%}
config host
option name '{{ name }}'
option dns '1'
option mac '{{ mac }}'
option ip '{{ subnet }}.{{ id }}'
{%
endfor
%}
Output:
$ ./dhcp_gen.uc
config host
option name 'host1'
option dns '1'
option mac 'xx:yy:zz:11:22:33'
option ip '192.168.2.104'
config host
option name 'host2'
option dns '1'
option mac 'yx:zy:xz:11:22:33'
option ip '192.168.2.106'
config host
option name 'dbmaster'
option dns '1'
option mac 'aa:bb:cc:11:22:33'
option ip '192.168.2.196'