Hi, I have changed my switch to serve as DHCP relay mode, and set an OpenWRT device as its responder.
The switch has two IP: 10.0.10.1/24 and 10.0.200.1/24. The first one is in the subnet of clients, and the second is together with the OpenWRT device (10.0.200.2/24).
[Client] --- (10.0.10.1/24-[Switch]-10.0.200.1/24) --- (10.0.200.2/24-[OpenWRT]
In dnsmasq.conf
, I could easily setup the relay responder according to its official example (line 163):
dhcp-range=10.0.10.150,10.0.10.200,255.255.255.0,12h
It seems that the 3rd field 255.255.255.0
plays an important role in working as a relay responder.
I'd like to do this in UCI config (/etc/config/dhcp
). But in the pool section of UCI config, I could never know which option value is corresponding to 255.255.255.0
.
A normal setup like
config dhcp 'clients'
option interface 'lan'
option start '100'
option leasetime '12h'
option limit '150'
will not work certainly because it's missing the subnet where it is serving and prints
daemon.warn dnsmasq-dhcp[10447]: no address range available for DHCP request via 10.0.10.1
after the device receives relayed DHCP Discover / Request.
Then I tcpdumped the traffic and found that the relay server sent a DHCP request to OpenWRT with source ip 10.0.10.1
, therefore the source IP can be regarded as a classifier. Thus I have also tried to add networkid
and tag
set as 10.0.10.1
, but neither of them work. The UCI documents also show none about classifier based on source IP, so I'm lost.
How can I get the relay responder work in UCI config?