Re: Fwd: /etc/hosts and resolving of the local host/domainname - 127.0.0.1 vs. 127.0.1.1
On Mon, 5 Aug 2013 13:08:28 -0400, Thomas Hood wrote:
(I had an exchange of emails with Thomas off-list and he suggested that
I reply on-list.)
> With the nsswitch configuration
> hosts: files ... dns ... myhostname
> myhostname resolves the system hostname if nothing else does so
> first. So it can be overridden either by DNS or by /etc/hosts. If
> the system hostname changes, no file has to be edited. Nice.
> Also nice is the fact that myhostname resolves the system hostname
> to an external address if there is one, increasing the chances that
> the result is similar to what would be obtained from DNS.
The output below is from Debian Sid with libnss-myhostname installed
and Fedora 19.
On Debian, getent outputs the system's IP address for 127.0.1.1,
whereas on Fedora, getent outputs 127.0.0.2 for 127.0.0.2.
[root@debdeb:/etc]# cat hostname
[root@debdeb:/etc]# cat hosts
[root@debdeb:/etc]# getent hosts 127.0.1.1
[root@fedfed:/etc]# cat hostname
[root@fedfed:/etc]# cat hosts
[root@fedfed:/etc]# getent hosts 127.0.0.2