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

Matus UHLAR - fantomas uhlar at fantomas.sk
Mon Oct 31 13:50:21 UTC 2022


Hello,

>>On Fri, Oct 21, 2022 at 11:23:28PM +0200, Michael Traxler wrote:
>>>dnsmasq-2.87:
>
>>>When you disable the DNS-server via
>>>port=0
>>>
>>>the /etc/hosts file is ignored and also the
>>>addn-hosts=<fn>
>>>is ignored.

I was able to reproduce this behaviour. with "port 0" the /etc/hosts seems 
not to be loaded and static leases configured using /etc/ethers and 
/etc/hosts are not honored.

with other ports (53 and 54 tested), dhcp leases are given as configured in 
/etc/hosts

This applies to dnsmasq 2.86 as long as it did to 2.80.

I even see in logs that hosts files aren't logged:

Oct 31 13:18:12 turris dnsmasq[11666]: started, version 2.86 cachesize 150
Oct 31 13:18:12 turris dnsmasq[11666]: read /etc/hosts - 28 addresses
Oct 31 13:18:12 turris dnsmasq[11666]: read /tmp/hosts/dhcp.cfg01411c - 3 addresses
Oct 31 13:18:12 turris dnsmasq[11666]: read /tmp/hosts/odhcpd - 1 addresses
Oct 31 13:18:12 turris dnsmasq-dhcp[11666]: read /etc/ethers - 24 addresses

Oct 31 13:26:13 turris dnsmasq[12187]: started, version 2.86 DNS disabled
Oct 31 13:26:13 turris dnsmasq-dhcp[12187]: read /etc/ethers - 24 addresses


>I'm not very skilled in C, so I can only guess:
>
>src/cache.c seems to ignore hosts cache when port is set to 0
>there may be of course different places the cache is filled
>
>#ifdef HAVE_DHCP
>struct in_addr a_record_from_hosts(char *name, time_t now)
>{
>  struct crec *crecp = NULL;
>  struct in_addr ret;
>
>  /* If no DNS service, cache not initialised. */
>  if (daemon->port != 0)
    ^^^^^^^^^^^^^^^^^^^^^^
I guess this the culprit


>    while ((crecp = cache_find_by_name(crecp, name, now, F_IPV4)))
>      if (crecp->flags & F_HOSTS)
>        return crecp->addr.addr4;
>
>  my_syslog(MS_DHCP | LOG_WARNING, _("No IPv4 address found for %s"), name);
>
>  ret.s_addr = 0;
>  return ret;
>}
-- 
Matus UHLAR - fantomas, uhlar at fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Quantum mechanics: The dreams stuff is made of.



More information about the Dnsmasq-discuss mailing list