[Dnsmasq-discuss] read /etc/hosts if DNS disabled

Geert Stappers stappers at stappers.nl
Sat Jun 6 14:52:35 BST 2020


On Thu, May 21, 2020 at 08:42:07PM +0200, Matus UHLAR - fantomas wrote:
> > On Thu, May 21, 2020 at 03:35:24PM +0200, Matus UHLAR - fantomas wrote:
> > > > On Fri, May 15, 2020 at 07:53:50PM +0200, Matus UHLAR - fantomas wrote:
> > > > > I have problems configuring static DHCP using /etc/hosts and /etc/ethers.
> > > > > It seems that dnsmasq is ignoring /etc/hosts when dns server is disabled
> > > > > via "-p 0" option.
> > > > >
> > > > > Can anyone confirm?
> > > > > If I'm right, is this bug or a feature?
> > > 
> > > On 21.05.20 15:03, Geert Stappers wrote:
> > > > Advice: Describe "the problem" better.
> > > 
> > > OK.
> > > 
> > > the problem is that DHCP clients listed in /etc/ethers will not be given IP
> > > addreses specified in /etc/hosts when dnsmasq does not run DNS service
> > > (-p 0), because /etc/hosts is not read in that case.
> > > 
> > > the workaround is to run DNS at different port (e.g.  -p 54), so dnsmasq
> > > reads /etc/hosts and provides IPS configured there do clients from
> > > /etc/ethers, but I believe /etc/hosts should be read even without DNS,
> > > unless explicitly disabled.
> 
> On 21.05.20 18:33, Geert Stappers wrote:
> > Acknowledge on version 2 of "problem description".
> > 
> > I partially understand what the expectations are.
> 
> 
> a litle background:
> 
> I used dnsmasq on openwrt router using /etc/ethers for machine<>ethernet
> address conversion and /etc/hosts for host to IP conversion (for both DHCP
> and DNS).
> 
> I bought new router with turris (openwrt clone) which uses knot-resolver
> (which uses /etc/hosts for local DNS) and runs dnsmasq only as DHCP server
> 
> The problem is that while in this scenario dnsmasq does use the ethers table
> (I can see that in reservations info), but it does not use hosts table to
> assign proper IP addresses for those hosts.
> 
> as a workaround I set dnsmasq to run DNS on another port (I'm thinking on
> disabling knot-resolvet) so while the DNS is not used, correct IP addresses
> are assigned.
> 
> I'd like dnsmasq to read /etc/hosts table for DHCP reservations even when
> DNS is not used.
> 
> ... I know I can work around reservations, but I find /etc/ethers and
> /etc/hosts good standards to use
> 

For what it worth, dnsmasq.conf.example has
<screenshot>
# If this line is uncommented, dnsmasq will read /etc/ethers and act
# on the ethernet-address/IP pairs found there just as if they had
# been given as --dhcp-host options. Useful if you keep
# MAC-address/host mappings there for other purposes.
#read-ethers
</screenshot>

I suggest to play with a dnsmasq.conf that has
<screenshot>
# dnsmasq should read /etc/ethers and act on the ethernet-address/IP pairs
# found there just as if they had been given as --dhcp-host options.
# Used for keeping MAC-address/host mappings there for other purposes.
read-ethers
</screenshot>


Regards
Geert Stappers
-- 
Silence is hard to parse



More information about the Dnsmasq-discuss mailing list