That "nss-myhostname" message & correcting the /etc/hosts file

Tom H tomh0665 at gmail.com
Wed Apr 15 15:42:33 UTC 2015


On Wed, Apr 15, 2015 at 6:49 AM, Adam Funk <a24061 at ducksburg.com> wrote:
>
> I'm getting the
>
>    systemd-hostnamed[15205]: Warning: nss-myhostname is not
>    installed. Changing the local hostname might make it
>    unresolveable. Please install nss-myhostname!
>
> message in my logcheck output. Looking it up says not to install the
> equivalent package but to fix the /etc/hosts file.
>
> <https://askubuntu.com/questions/453072/what-is-nss-myhostname-and-why-is-it-not-installable>
>
> This is on a recent clean install of 14.04, upgraded immediately to
> 14.10 (because someone in the office had a 14.04 CD handy), using
> DHCP. I have not manually altered any of the networking stuff since
> the installation. The only thing possibly funny that I see in
> /etc/hosts is that the "127.0.0.1  localhost" line is followed by one
> with "127.0.0.1" and the hostname that the DHCP server gave (in fully
> qualified and short forms).
>
> Should I delete the second line?
>
> Why does the Ubuntu installation set up /etc/hosts wrong?

Ubuntu sets up "/etc/hosts" in this way:

<begin>
127.0.0.1 localhost ...
127.0.1.1 <hostname>.<domainname> >hostname
</end>

(not "127.0.1.1 <hostname>.<domainname> <hostname>") but hostnamectl
doesn't update "/etc/hosts" when you use it to change the hostname,
because nss-myhostname (libnss-myhostname in Ubuntu) is part of
systemd upstream; hence the warning.

Steve L's objection no longer applies (and might not have applied when
he posted to Launchpad) because Ubuntu patches libnss-myhostname to
use 127.0.1.1 rather than 127.0.0.2 as set up upstream.

I use libnss-myhostname on the Ubuntu systems that I manage. Here's
the output from my laptop running 15.04:

<begin>
# cat /etc/hosts
127.0.0.1    localhost
# getent hosts 127.0.0.1
127.0.0.1       localhost
# getent hosts 127.0.0.2
# getent hosts 127.0.1.1
192.168.1.11    yoga.lenovo
</end>

There was a thread here last November [1] where the OP decided not to
install libnss-myhostname.

Strangely, libnss-myhostname on Debian and Ubuntu differs from
nss-myhostname upstream in the way that 127.0.1.1 is resolved but I
guess that it isn't a big deal.

[1] https://lists.ubuntu.com/archives/ubuntu-users/2014-November/278766.html




More information about the ubuntu-users mailing list