[Dnsmasq-discuss] dnsmasq: dhcp-server with disabled dns-server: /etc/hosts ignored

Simon Kelley simon at thekelleys.org.uk
Mon Oct 31 21:07:40 UTC 2022



On 21/10/2022 22:23, Michael Traxler wrote:
> Hello,
> 
> dnsmasq-2.87:
> 
> It took me quite some time to figure this out :-)
> 
> When you disable the DNS-server via
> port=0
> 
> the /etc/hosts file is ignored and also the
> addn-hosts=<fn>
> is ignored.
> 
> This then results in the problem, that the
> DHCP-server still works, but if you use the
> 
> dhcp-host=da:7a:3a:62:7d:d2,trb
> 
> where trb is a name in /etc/hosts
> dnsmasq reacts with:
> 
> DHCPDISCOVER(enp2s0) da:7a:3a:62:7d:d2 no address available
> 
> I checked via strace that it really doesn't even open
> /etc/hosts nor the given file via the "addn-hosts" option.
> 
> Looks for me like a bug. I can not find a logical reason, why a dhcp-server
> *needs* to have a running DNS-server.
> 
> Or is it a feature? :-)

It's at least a documentation bug. I think the reasoning behind the 
behaviour is that setting port=0 disables all the DNS functionality, 
which can be useful for its own sake, but also saves machine resources; 
no memory is allocated for cache and all the configuration 
infrastructure for DNS is not initialised, hence /etc/hosts doesn't get 
read.

It would be trivial to remove half a dozen "if (port != 0) {   }" lines 
from the code, and have all of the DNS stuff still live apart from 
actually listening on port 53, but that's not necessarily an 
improvement. There's not increase in functionality, since the same 
behaviour can be configured simply by adding the the addresses to the 
dhcp-host lines and that works with the existing code even when port=0 
is set.


My feeling is that the best fix to this is a heads-up in the man page, 
but I'm happy to entertain arguments to the contrary.

Simon.


> 
> Thanks a lot,
> 
> Michael
> 
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss
> 



More information about the Dnsmasq-discuss mailing list