I am configuring a minimal Ubuntu-Desktop (vanilla Ubuntu Server + the meta package ubuntu-desktop-minimal
) and the user/admin should be able to easily change the hostname, as this is needed from time to time.
When changing the hostname via GNOME (or systemd for that matter), it is only changing /etc/hostname
but not /etc/hosts
.
The recommended systemd-way to avoid problems due to this behavior, is using nss-myhostname
.
Although it seems to be controversial in the Ubuntu community (see post and links) I installed libnss-myhostname
(and libnss-resolve
, but I am unsure if this is actually needed).
Anyway nss-myhostname does not have the expected effect.
I commented the following line in the /etc/hosts
out: 127.0.1.1 108-0001
And I changed the hosts
line in /etc/nsswitch.conf
to: hosts: resolve [!UNAVAIL=return] files myhostname dns
.
When I test my setting with getent ahosts `hostname`
as suggested by the man-page I get the following result:
$ getent ahosts `hostname`
fe80::d24c:c1ff:fe05:bd71%2 STREAM 108-0001
fe80::d24c:c1ff:fe05:bd71%2 DGRAM
fe80::d24c:c1ff:fe05:bd71%2 RAW
192.168.1.55 STREAM
192.168.1.55 DGRAM
192.168.1.55 RAW
At least the hostname can be resolved but it is not resolved to the expected 127.0.0.2
and ::1
.
What am I doing wrong or are my expectations wrong?