A massive thank you to @pavelgl who helped immensely; The below is his write-up with two complete recipes for approaches.
--=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=
There are two possible options:
A) The whole configuration could be set in /etc/config/dhcp, using the UCI syntax.
You could create a tagged group with individual DHCP options for the IOT devices and then create a static lease for each device, assigning IP addresses outside the regular DHCP pool (the tags are not visible in LuCI).
Example with custom DNS and disabled default gateway:
uci set dhcp.iot="tag"
uci add_list dhcp.iot.dhcp_option="6,192.168.1.6,192.168.1.7"
uci add_list dhcp.iot.dhcp_option="3"
uci add dhcp host
uci set dhcp.@host[-1].name="iot1"
uci set dhcp.@host[-1].mac="XX:XX:XX:XX:8d:88"
uci set dhcp.@host[-1].ip="192.168.4.48"
uci set dhcp.@host[-1].tag="iot"
uci add dhcp host
uci set dhcp.@host[-1].name="iot2"
uci set dhcp.@host[-1].mac="XX:XX:XX:XX:8d:89"
uci set dhcp.@host[-1].ip="192.168.4.49"
uci set dhcp.@host[-1].tag="iot"
uci commit dhcp
/etc/init.d/dnsmasq restart
In /etc/config/dhcp
the configuration should look like this:
config tag 'iot'
list dhcp_option '6,192.168.1.6,192.168.1.7'
list dhcp_option '3'
config host
option name 'iot1'
option mac 'XX:XX:XX:XX:8d:88'
option ip '192.168.4.48'
option tag 'iot'
config host
option name 'iot2'
option mac 'XX:XX:XX:XX:8d:89'
option ip '192.168.4.49'
option tag 'iot'
You can use copy / paste if it's easier for you.
B) If you insist on a separate DHCP pool, you must use an additional custom configuration file, using the native dnsmasq syntax.
Move the dnsmasq additional configuration directory from tmp
to etc
:
uci set dhcp.@dnsmasq[0].confdir=/etc/dnsmasq.d
uci commit dhcp
/etc/init.d/dnsmasq restart
Here is the analog of the previous configuration, but here is used a separate DHCP pool and the dnsmasq syntax. The additional file must be located in /etc/dnsmasq.d/
. You can use any filename.
dhcp-mac=set:iot,XX:XX:XX:XX:8d:88
dhcp-mac=set:iot,XX:XX:XX:XX:8d:89
dhcp-range=tag:iot,192.168.4.10,192.168.4.20,12h
dhcp-option=tag:iot,option:dns-server,192.168.1.6,192.168.1.7
dhcp-option=tag:iot,option:router
In any case, you will need to manually enter the MAC address of each IOT device in order to set the tag, so I would recommend using option A. Option B is not so "canonical" and does not save you much work.