Generally all works just was surprised to see dhcp.leases and hosts/dhcp files acting differently.
/tmp/dhcp.leases.* act as expected they only list the leases of the respective interface. But /tmp/hosts/dhcp.* files show all leases (hosts) across all interfaces (as you can see on the size of them.
root@router:/# ls -lah /tmp/dhcp.leases.*
-rw-r--r-- 1 root root 75 Jan 8 08:06 /tmp/dhcp.leases.guest
-rw-r--r-- 1 root root 723 Jan 8 13:28 /tmp/dhcp.leases.lan
-rw-r--r-- 1 root root 564 Jan 8 13:17 /tmp/dhcp.leases.media
root@router:/# ls -lah /tmp/hosts/dhcp.*
-rw-r--r-- 1 root root 1.0K Jan 8 13:14 /tmp/hosts/dhcp.guest_dns
-rw-r--r-- 1 root root 1.0K Jan 8 13:14 /tmp/hosts/dhcp.lan_dns
-rw-r--r-- 1 root root 1.0K Jan 8 13:15 /tmp/hosts/dhcp.media_dns
Questions I have:
Is this behavior normal/expected that the /tmp/hosts/ files include all hosts and not only the ones from the interface?
If you want to actually on one specific interface to have all hosts resolutions available (while keeping the other interfaces restricted to their names) what would be the suggest approach? Have them separated as above and then have a cronjob that combines the three lease files together for one interface?
Actually more testing revealed it seems not to work as expected. It seems all names (if you use the FQN) can be resolved from each DNS server on each interface. That would indicate that they use /tmp/hosts/ to resolve. So question how to ensure that hosts files only receive the hosts from the local interface (DHCP Leases).
EDIT:
Which I could already have figured out from the log file
Jan 8 11:53:11 router dnsmasq[31253]: read /tmp/hosts/dhcp.guest_dns - 33 addresses
Jan 8 11:53:11 router dnsmasq[31252]: read /tmp/hosts/dhcp.lan_dns - 34 addresses
Jan 8 11:53:11 router dnsmasq[31254]: read /tmp/hosts/dhcp.lan_dns - 34 addresses
Jan 8 11:53:11 router dnsmasq[31253]: read /tmp/hosts/dhcp.media_dns - 34 addresses
Jan 8 11:53:11 router dnsmasq[31254]: read /tmp/hosts/dhcp.guest_dns - 33 addresses
Jan 8 11:53:11 router dnsmasq[31252]: read /tmp/hosts/dhcp.guest_dns - 33 addresses
So question remains how do I influence how the hosts files are generated and used by the DNS servers?
are you using config host / config domain? you can add option instance <dnsmasq instance name> to bind to dnsmasq instance. this requires "named" config dnsmasq sections.
e.g.
config dnsmasq 'landns'
option ...
config dnsmasq 'guestdns'
option ...
config host
option mac 'xx:xx:xx:xx:xx:xx'
option name 'client01'
option instance 'landns'
config host
option mac 'xx:xx:xx:xx:xx:xx'
option name 'client02'
option instance 'guestdns'
this setup will attach host config to respective dnsmasq instance and makes them available only for the respective dns / dhcp domain (controlled by the dnsmasq instance).
note: maybe using option dhcphostsfile is a more comfortable way to setup hosts imho. From luci you cannot bind host config to an instance, you need to edit /etc/config/dhcp anyhow. but if you put your host config into a dhcp hosts file or directory you have the benefit that it can be edited and then reloaded instead of full restart.
@grrr2
Many thanks for your feedback. I had already the individual dnsmasq instances configured. The missing part was the option instance in each of the config host entries.
How about config domain entries, seems they don't support the `option instance' or? Most likely the dhcphostfile approach would fit for them.