Different domain for each interface

I have multiple LAN interfaces (using VLANs), and I'd like to use a different DNS domain for each. I'm referring to the domain to which DHCP hosts are added to, rather than the DNS search domain list passed back by DHCP.

ie I'd like one subnet to get an xyz.home.arpa suffix and another iot.home.arpa.

This corresponds to the domain= option in dnsmasq (https://dnsmasq.org/docs/dnsmasq-man.html).

-s, --domain=<domain>[[,<address range>[,local]]|<interface>]
Specifies DNS domains for the DHCP server. Domains may be be given unconditionally (without the IP range) or for limited IP ranges. This has two effects; firstly it causes the DHCP server to return the domain to any hosts which request it, and secondly it sets the domain which it is legal for DHCP-configured hosts to claim.

dnsmasq allows this to be specified by DHCP pool or per interface, but I don't see any way to do this in UCI. Is there a way?

Make multiple instances of dnsmasq.

That would work, but then can it still be managed from LuCI? eg assigning reserved leases.

The other alternative I see would be to use the dhcp.@dnsmasq[0].confdir setting to manually add to the dnsmasq configuration. This assumes dnsmasq will do the right thing with a default domain= setting and additional per-interface/range domain= settings.

Yes, it works fine.

If I have an instance per subnet, how do they know what hosts are on the other subnets? ie how do cross-subnet DNS lookups work?

I guess this would need --server setting(s) for each dnsmasq pointing to the other subnets' dnsmasqs:

-S, --local, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>]][@<interface>][@<source-ip>[#<port>]]

Yes, but you can add that in uci configuration list server '/example.com/10.0.1.1'

1 Like

I think you can do so by using dhcp scope option 15 on the interface like this

Option 15 will assign all of them to the same interface.

1 Like

Network > DHCP and DNS > Hostnames

OpenWrt 22.03 up