What is nss-myhostname? And why is it not installable?

dmesg shows the line

systemd-hostnamed[3964]: Warning: nss-myhostname is not installed. 
Changing the local hostname might make it unresolveable. Please install nss-myhostname!    

But

sudo apt-get install nss-myhostname

says

Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.       
Statusinformationen werden eingelesen.... Fertig
E: Paket nss-myhostname kann nicht gefunden werden.

...meaning "nss-myhostname not found".

Why? Do I have to react on the dmesg message?


Solution 1:

There is a confirmed bug logged against systemd-hostnamed saying;

Since nss-myhostname was rejected as being the right approach in https://bugs.launchpad.net/ubuntu/+source/libnss-myhostname/+bug/1162478/comments/6 , we should not print the warning message in the LTS release, even if hostnamed doesn't currently modify /etc/hosts.

Can we please patch this warning out to prevent users from thinking something is wrong on their system and leading them to install libnss-myhostname?.

Even though it may avoid the warning, you may not want to install libnss-myhostname for that purpose only.

Any body seeing the message

 systemd-hostnamed
[16495]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!

must read this https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1277608 this https://bugs.launchpad.net/ubuntu/+source/libnss-myhostname/+bug/1162478/comments/6 before installing the nss-myhostname package.

Solution 2:

From here:

nss-myhostname is a plugin for the GNU Name Service Switch (NSS) functionality of the GNU C Library (glibc) providing hostname resolution for the locally configured system hostname as returned by gethostname(2) There are two possible solutions:

  • You may have not (or incorrectely) configured your hostname in /etc/hosts. Correcting that may resolve this.

  • Another way, as the warning suggests, is to install nss-myhostname, which is referred to in debian as libnss-myhostname. This is only a workaround, not the suggested solution to the relevant bug. Install using:

    sudo apt-get install libnss-myhostname
    

Source: 13.04 dmesg: Warning: nss-myhostname is not installed

Solution 3:

I doubt you will want to install those libraries. Seen as it's nothing more than a nuisance you can simply silence the message.

Create a new config file in /etc/rsyslog.d/ and tell the message to be dropped:

$ sudo nano /etc/rsyslog.d/20-systemd-hostnamed.conf

Add the following single line:

:msg, contains, "Warning: nss-myhostname is not installed." stop

Save and close, and restart the daemon:

$ sudo service rsyslog restart

Job done. You can make sure that the messages are being dropped by intentionally trying to spam your syslog:

$ logger -t TEST "Warning: nss-myhostname is not installed."

The message should be silently dropped.