[Dnsmasq-discuss] Questions about /etc/hosts
Chris Green
cl at isbd.net
Fri Feb 11 08:56:15 UTC 2022
oN fRI, fEB 11, 2022 AT 07:30:51am +0100, gEERT sTAPPERS VIA dNSMASQ-DISCUSS WROTE:
> On Fri, Feb 11, 2022 at 12:24:27AM +0100, Petr Menšík wrote:
> > On 2/10/22 20:24, Chris Green wrote:
> > > When running dnsmasq it (by default) uses /etc/hosts to provide some
> > > system's addresses.
> > >
> > > Some of my systems have their names in the /etc/hosts file against
> > > a loopback address so host t470 has:-
> > >
> > > 127.0.0.1 localhost
> > > 127.0.1.1 t470.zbmc.eu t470
> > >
> > >
> > > While others only have their names against their (static) IP address
> > > so host backup has:-
> > >
> > > 192.168.1.1 2860n # Draytek router, internet
> > > 192.168.1.2 dns.zbmc.eu dns # this Pi running dnsmasq
> > > 192.168.1.3 esprimo zbmc.eu # my desktop system
> > > 192.168.1.4 backup.zbmc.eu backup # backup Raspberry Pi, also DNS/DHCP backup
> > >
> > >
> > > Is that 127.0.1.1 loopback address just so that there is an IP for a
> > > system to refer to itself (particularly in the case where it has DHCP
> > > assigned IP so there isn't a fixed address for itself)?
> > >
> > >
> > > Where a system has a static/fixed IP is it OK to have only the
> > > 'localhost' loopback address and the 'real' static IP for 'self'?
> > > E.g. can one have:-
> > >
> > > 127.0.0.1 localhost
> > >
> > > 192.168.1.1 2860n # Draytek router, internet
> > > 192.168.1.2 dns.zbmc.eu dns # this Pi running dnsmasq
> > > 192.168.1.3 esprimo zbmc.eu # my desktop system
> } } 192.168.1.3 esprimo.zbmc.eu # my desktop system
> > > 192.168.1.4 backup.zbmc.eu backup # backup Raspberry Pi, also DNS/DHCP backup
> > >
> > > As the /etc/hosts file on all of those systems (which have static IP)?
> > >
> > I think we would need to know, which distribution and version you are
> > running.
>
> And which computer of them is running dnsmasq as Domain Name Server
> for the other computers.
>
Currently 'dns' is running dnsmasq as the DHCP/DNS server for the LAN,
however these questions are as a result of me wanting to move that
service to one of the other systems on the LAN.
> > /etc/hosts is not directly controlled by dnsmasq.
>
> dnsmasq, as DNServer, uses /etc/hosts as source
> for hostname-IPaddress-mapping. Consider it as source of a single thruth.
>
> Back to
> > > As the /etc/hosts file on all of those systems (which have static IP)?
>
> That is fairly ignorant. The whole idea of DNS is eliminating the
> maintainance of /etc/hosts files. And having hostname-IPaddress-mapping
> in several places (/etc/hosts and DNS) creates several thruths, which
> should be avoided.
>
Yes, I know, but *some* systems have to have static IP:-
192.168.1.1 The VDSL router, not *absolutely* necessary but it is the default route
192.168.1.2 This is the DHCP/DNS server so has to be static
192.168.1.3 This is SMTP server among other things, if DNS fails I need it to remain as 192.168.1.3
192.168.1.4 Going to become backup DHCP/DNS
--
Chris Green
More information about the Dnsmasq-discuss
mailing list