How network manager is resolving localhost without /etc/hosts
ubuntu at tigershaunt.com
Mon Dec 28 22:12:00 UTC 2015
On 15-12-28 04:57 PM, Shashwat Kumar wrote:
> I got stuck in some other problem where NM was not reading from
> /etc/hosts. I wondered that since it wasn't reading hosts file, then how
> localhost was still working. Then I found it interesting to find out how
> actually localhost was getting resolved. There is not any techical issue
> thats obstructing me. Its just for learning purpose.
I don't really know how changing nsswitch.conf might affect a system,
(that's always been a black box not touch file, other than adding Wins
with samba bind package, but that's another story.)
But check your resolv.conf file, See what dns servers your system is
using at a low level.
try to query localhost on each of them.
$host localhost ip_of_dns_server
If any returns 127.0.0.1, you know where that's coming from. Note that
with NM using it's own dns server, the IP of your dns server on system
is probably itself 127.0.0.1, otherwise, it should be the DNS assigned
by your DHCP/Router/Gateway.
Also, you can change the IP address of Localhost in your hosts file,
regardless of NM settings, if you set the ip to 127.0.0.2 in hosts file,
and ping localhost, that should be the IP address that gets pinged,
assuming hosts file is still the first source of name lookup.
More information about the ubuntu-users