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.
Debian Sid
[root@debdeb:/etc]# cat hostname
debdeb
[root@debdeb:/etc]# cat hosts
127.0.0.1 localhost
[root@debdeb:/etc]# getent hosts 127.0.1.1
192.168.1.250 debdeb
Fedora 19
[root@fedfed:/etc]# cat hostname
fedfed.defdef
[root@fedfed:/etc]# cat hosts
127.0.0.1 localhost
[root@fedfed:/etc]# getent hosts 127.0.0.2
127.0.0.2 fedfed.defdef
Reply to: