NixOS / nixops

NixOps is a tool for deploying to NixOS machines in a network or cloud.
https://nixos.org/nixops
GNU Lesser General Public License v3.0
1.82k stars 363 forks source link

Generated /etc/hosts does not contain own hostname #106

Closed zefhemel closed 11 years ago

zefhemel commented 11 years ago

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 a myhostname-encrypted entry.

edolstra commented 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.

zefhemel commented 11 years ago

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.

edolstra commented 11 years ago

I don't get it. Apparently your hostname resolves to a valid IP address. Isn't that what you want?

zefhemel commented 11 years ago

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.

zefhemel commented 11 years ago

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.

edolstra commented 11 years ago

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.)

zefhemel commented 11 years ago
$ host builder
builder.pl              A   176.9.79.79