Closed zefhemel closed 11 years ago
/etc/hosts doesn't need to contain the system's hostname because we use nss_myhostname, which dynamically returns the right IP address(es) for the hostname.
Well, it doesn't seem to work. When I ping my own hostname, it tries to resolve it to myhostname.pl or something. When I add this:
networking.extraHosts = ''
127.0.0.1 myhostname
'';
Everything works again.
I don't get it. Apparently your hostname resolves to a valid IP address. Isn't that what you want?
My machine is called builder. If I do ping builder
on the machine itself, it resolves to the IP of builder.pl
(quite frankly, don't ask my why) which is not what I want, I want it to resolve to 127.0.0.1.
Just looked at what nss_myhostname is supposed to do and that sounds good, but for some reason it doesn't work for me. My guess is that when I ping "builder" and it cannot resolve it, it starts appending localized TLDs, starting with .pl because that's where I live. Or perhaps it's a feature of my ISPs DNS server.
Certainly nss_myhostname doesn't do that. Maybe you have "domain pl" in /etc/resolv.conf (possibly on the host)? Or the nameserver in your router does weird things...
Note that nss_myhostname only gets called if a DNS lookup doesn't return a value. What does "host builder" say? (The "host" command doesn't use NSS modules.)
$ host builder
builder.pl A 176.9.79.79
Some services (e.g. rabbitmq) bind to the machine's hostname. However, as this hostname is not generated into
/etc/hosts
, it cannot resolve it./etc/hosts
does contain all other hostnames of machines in the network and even amyhostname-encrypted
entry.