How network manager is resolving localhost without /etc/hosts

Rashkae ubuntu at tigershaunt.com
Mon Dec 28 16:13:17 UTC 2015


On 15-12-28 05:09 AM, Tom H wrote:
> Give "dig @8.8.8.8 localhost." or "dig @208.67.222.222 localhost." a 
> try and let us know whether you get an answer; "localhost" is special. 

NXDOMAIN, which is what I would expect.  When I said it would resolve by 
DNS, I meant the resolver library would query DNS if localhost is not in 
/hosts.  Whether or not DNS responds with 127.0.0.1 would then depend on 
configuration of the DNS server to which that query is made.


> The OP,  AFAIU, set "<ip_address> localhost" in "/etc/hosts" where
> ip_address isn't "127.0.0.1" but localhost was still being resolved as
> "127.0.0.1" because the OP hadn't set "dns=none" in the NM
> configuration.
>

No, the IP tried commenting every line in /hosts, was surprised 
localhost was still resolving, and assumed, because of another problem 
they were having, that Network Manager dns caching was taking priority 
over /etc/hosts.

My points are:

1. dns cache server resolving localhost in the absense of an entry in 
hosts file is normal.  (while I haven't tested the dnsmasq software used 
by Network Manager, it is, indeed, the default configuration of Bind to 
do so.)

2.  If hostnames in hosts file are indeed resolving to something else 
when NM dns caching is in play, *that* is an issue of resolve order, 
(or, I think, more likely, something done wrong in the hosts file, as 
not many would ever touch nsswitch).  In either way, the default config 
of Network Manager should not in any way bypass hosts file.  Name 
resolution by other programs has nothing to do with Network Manager 
config, other than the DNS servers used when the query gets to that point.







More information about the ubuntu-users mailing list