Multiple dnsmasq instances

I'm trying to configure multiple dnsmasq instances for testing purposes, however i hit a roadblock.
For testing i can successfully get 2 instances up, with their own domain. Here's the dhcp config:

root@OpenWrt:/etc/config$ cat /etc/config/dhcp

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

config dnsmasq 'lan_dns'
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '0'
        option rebind_localhost '0'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases.lan'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        list addnhosts '/tmp/hosts/'
        list interface 'lan'

config dhcp 'lan'
        option instance 'lan_dns'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'

config dnsmasq 'iot_dns'
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '0'
        option rebind_localhost '0'
        option local '/iot/'
        option domain 'iot'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases.iot'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        list addnhosts '/tmp/hosts/'
        list interface 'iot'
        list notinterface 'loopback'

config dhcp 'iot'
        option instance 'iot_dns'
        option interface 'iot'
        option start '100'
        option limit '150'
        option leasetime '12h'

It's pretty basic. Client A connected to the lan network, gets his ip from dhcp. The client is added to the lan dhcp server lease file. nslookup works from the client, for his subnet.
Now comes client B on the iot network. He gets his ip, and dns lookups works for his own subnet.
But no matter how i tried, i cannot make it that client A could resolve fqdn names from the other dnsmasq instance .
I have lease files: dhcp.leases.iot and dhcp.leases.lan. Both contain their own leases.
I also have dhcp.iot_dns and dhcp.lan_dns hosts files. Dynamic dhcp leases do not get added to the hosts files.
I'm kinda lost how to do it this way.

Any help appreciated, thanks!

Set DNS B as upstream DNS for DNS A ?

Ain't there any more elegant solution? When you have 5-10 instances, that would be impossible to follow.

Use sub-domains, rather than domains.

Maybe
server=/iot/lan-ipaddress-iot

1 Like

Thanks, but i expected the solution using mutliple instances will be cleaner and easier compared to one instance of dnsmasq, with tags.

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '0'
        option rebind_localhost '0'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'

config dhcp 'iot'
        option interface 'iot'
        option start '100'
        option limit '150'
        option leasetime '12h'

I need to add this to /etc/dnsmasq.conf then everything works perfectly:

domain=lan,192.168.1.0/24,local
domain=iot,192.168.99.0/24,local

Unfortunately i couldn't find a way to add multiple domain lines to /etc/config/dhcp, so i had to directly modify dnsmasq.conf.