[Dnsmasq-discuss] Questions about /etc/hosts

Matus UHLAR - fantomas uhlar at fantomas.sk
Fri Feb 11 19:25:31 UTC 2022


On 10.02.22 19: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)?

debian and its derivatives do this (127.0.1.1 to local hostname), so:

- the hostname is always reachable even if there's no network connection
- 127.0.0.1 always maps to localhost (anything else could cause troubles).

>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'?

yes.  I usually do this, so my hostname is reachable in case of DNS failure

>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.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)?

as was already mentioned, the point of DNS is to avoid need to copy 
/etc/hosts contents.

OTOH, I configured /etc/hosts on my home router, and dnsmasq can read it and 
use for both DNS and DHCP.

-- 
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.
There's a long-standing bug relating to the x86 architecture that
allows you to install Windows.   -- Matthew D. Fuller



More information about the Dnsmasq-discuss mailing list