Multiple dnsmasq configs (stupid?)

Hi,

I am having an issue with dnsmasq on 3 separate interfaces.

This has always worked correctly but somewhere along the way of upgrading to openwrt version 22.x things started to get messy:
In /tmp/hosts/dhcp.* I get all systems in every dhcp file:

dhcp.guest_dns:192.168.178.13 machine1.blabla.guest
dhcp.lan_dns:192.168.178.13 machine1.blabla.lan
dhcp.vpnlan_dns:192.168.178.13 machine1.blabla.vpn

I am probably missing some option in my config, but for the life of me, I can't find it...

what if you'd show your config?

config interface 'lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option ipaddr '192.168.178.252'
	option delegate '0'
	list dns '192.168.178.204'
	option ipv6 'off'
	option device 'br-lan'
	option gateway '192.168.178.1'

config interface 'guest'
	option proto 'static'
	option ipaddr '172.23.220.1'
	option netmask '255.255.255.0'
	option delegate '0'
	option dns '149.112.112.10'


config interface 'vpnlan'
	option proto 'static'
	option type 'bridge'
	option ipaddr '172.16.12.1'
	option netmask '255.255.255.0'
	option delegate '0'
	list dns '103.86.96.100'
	list dns '103.86.99.100'


config dnsmasq 'lan_dns'
	option domainneeded '1'
	option rebind_protection '0'
	option local '/polleke.lan/'
	option domain 'polleke.lan'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases.lan'
	option resolvfile '/etc/resolv.conf.lan'
	list interface 'lan'
	list notinterface 'guest'
	list notinterface 'vpnlan'
	option confdir '/tmp/dnsmasq.d'
	option localservice '1'

config dhcp 'lan'
	option instance 'lan_dns'
	option interface 'lan'
	option logqueries '1'
	option logfacility 'syslog'
	option start '150'
	option limit '50'
	option leasetime '12h'
	list dhcp_option '6,192.168.178.204'
	list ra_flags 'none'

config dnsmasq 'guest_dns'
	option domainneeded '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/polleke.guest/'
	option domain 'polleke.guest'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases.guest'
	option resolvfile '/etc/resolv.conf.guest'
	list interface 'guest'
	list notinterface 'lan'
	list notinterface 'vpnlan'
	list notinterface 'loopback'
	option localservice '1'

config dhcp 'guest'
	option instance 'guest_dns'
	option interface 'guest'
	option start '100'
	option limit '50'
	option leasetime '12h'

config dnsmasq 'vpnlan_dns'
	option domainneeded '1'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/polleke.vpn/'
	option domain 'polleke.vpn'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases.vpnlan'
	option resolvfile '/etc/resolv.conf.vpnlan'
	list interface 'vpnlan'
	list notinterface 'lan'
	list notinterface 'guest'
	list notinterface 'loopback'
	option localservice '1'

config dhcp 'vpnlan'
	option instance 'vpnlan_dns'
	option interface 'vpnlan'
	option start '100'
	option limit '50'
	option leasetime '12h'

if i understand correctly you upgraded from previous version keeping your configuration which is not the recommendation devs made. might worth a shot (after taking backup) to start from scratch.

But i guess your actual problem is that there is no dedicated option dhcphostsfile for each dhsnamsq instance.

thanx for the reply, added the dhcp-hostsfile option to the various configs, but to no avail...

I think I will just reconfigure everything from scratch... (never a bad idea)

did you create the hosts files before (re)started dnsmasq service?

according to code only adds hostfile option if file exists:

 config_get hostsfile "$cfg" dhcphostsfile
        [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile"

I think these are created from entries in /etc/config/dhcp:

config host
        option mac '00:05:cd:43:54:77'
        option leasetime '24h'
        option dns '1'
        option ip '192.168.178.13'
        option name 'x4100'

But then this is the result:
/tmp/hosts/ :
dhcp.guest_dns:192.168.178.13 x4100.blabla.guest
dhcp.lan_dns:192.168.178.13 x4100.blabla.lan
dhcp.vpnlan_dns:192.168.178.13 x4100.blabla.vpn

just found this one:

instance: Dnsmasq instance to which the host section is bound; if not specified the section is valid for all dnsmasq instances.

I'll try that one

and that did it...

Only "problem" is that u can't do this from the gui...

so in /etc/config/dhcp:

config host
        option mac '00:05:cd:43:54:77'
        option leasetime '24h'
        option dns '1'
        option ip '192.168.178.13'
        option name 'x4100'
        **option instance 'lan_dns'**
1 Like

yes, that is needed. but i assumed as you already used option instance elsewhere, you'd use the same approach for config host too. anyhow, glad you found the solution.

Like mentioned before, this looks like a "new" option which was introduced somewhere along the way...

Thanks for thinking with me!