Set dnsmasq as a DHCP relay responder in UCI

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: and The first one is in the subnet of clients, and the second is together with the OpenWRT device (

[Client] --- ([Switch]- --- ([OpenWRT]

In dnsmasq.conf, I could easily setup the relay responder according to its official example (line 163):


It seems that the 3rd field 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

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

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, therefore the source IP can be regarded as a classifier. Thus I have also tried to add networkid and tag set as, 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?

Create an alias interface in the target subnet and add a DHCP pool attached to that alias.

Does it imply that I have to assign another IP in the target subnet for the alias interface? Is it possible to achieve that without assigning extra IP?

Using a configured interface appears to be necessary, and OpenWrt is already connected to the target subnet via the switch, so adding a static IP is justified.

Well, actually these subnets are separated by VLAN. And the interface of can semantically only have addresses of I think it's quite weird to add an IP on OpenWRT which is unreachable unless additional routes are added to the L3 switch. Maybe I should turn to dnsmasq.conf. Anyway, thanks a lot for your help! :slight_smile:

1 Like