On 23/02/2021 09:13, Dominik Derigs wrote:
> Hey list,
> 
> When specifying a DHCP host like
> 
> --dhcp-host=00:20:e0:3b:13:af,192.168.0.2,wap
> 
> I'd expect dnsmasq to respond to `dig wap` with the IP address
> `192.168.0.2`. Instead, NOERROR with empty answer RR is returned.
> 
> Looking at the source code, this is expected as `lease_update_dns()`
> loops over `struct dhcp_lease *leases` which do not contain the devices
> configures by `--dhcp-host`. These are stored in `daemon->dhcp_conf`
> and iterated over only when devices request a lease.
> 
> If the device now requests a lease, `wap` is added to `*leases` and the
> leases database file from where it is also read from there on
> subsequent restarts (the `--dhcp-host` isn't needed anymore).
> 
> My `dig wap` now works as expected as `wap` is in `*leases`.
> 
> My question: Is not adding --dhcp-host hosts to the DNS cache a bug or
> is this somehow intended behavior?
> 

This is almost a FAQ. It's intended behaviour, because you can have
multiple DHCP host records for the same MAC address with different
addresses on different subnets. Only the address which matches the
subnet where the host last created or renewed a DHCP lease is active.
This makes, eg, a laptop which turns up on different wireless networks
useful.

To get the behavior you want, put the IP address and name into
/etc/hosts, or use --host-record.

Simon.


_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to