[hostnamed] Changing hostname doesn't update /etc/hosts

Bug #1162475 reported by Jeremy Bicha on 2013-03-31
This bug affects 71 people
Affects Status Importance Assigned to Milestone
gnome-control-center (Debian)
Fix Released
gnome-control-center (Ubuntu)
systemd (Ubuntu)
unity-control-center (Ubuntu)

Bug Description

1a. Run sudo gnome-control-center, or...
1b. Save the gnome-control-center.pkla from https://bazaar.launchpad.net/~ubuntu-desktop/gnome-control-center/ubuntu/revision/556 to /var/lib/polkit-1/localauthority/10-vendor.d/ and then run gnome-control-center as an admin user

2. Enter the Details panel
3. The "Device name" (hostname) text field should be editable; change the text to something else.
4. The hostname is updated instantly which can be verified by looking in /etc/hostname. However /etc/hosts/ is not updated.

Command line
hostnamectl set-hostname

The hostnamed documentation at http://www.freedesktop.org/wiki/Software/systemd/hostnamed says
"To properly handle name lookups with changing local hostnames without having to edit /etc/hosts for them we recommend using hostnamed in combination with nss-myhostname: http://0pointer.de/lennart/projects/nss-myhostname/ "

Without /etc/hosts being handled correctly, the hostnamed integration is only half-working.

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: gnome-control-center 1:3.6.3-0ubuntu18
ProcVersionSignature: Ubuntu 3.8.0-15.25-generic 3.8.4
Uname: Linux 3.8.0-15-generic x86_64
ApportVersion: 2.9.2-0ubuntu5
Architecture: amd64
Date: Sun Mar 31 08:52:57 2013
MarkForUpload: True
SourcePackage: gnome-control-center
UpgradeStatus: No upgrade log present (probably fresh install)
 activity-log-manager-control-center 0.9.4-0ubuntu6.1
 deja-dup 26.0-0ubuntu1
 gnome-control-center-signon 0.1.5-0ubuntu1
 gnome-control-center-unity 1.2daily13.02.15-0ubuntu1
 indicator-datetime 12.10.3daily13.03.26-0ubuntu1

Jeremy Bicha (jbicha) wrote :
description: updated
Jeremy Bicha (jbicha) wrote :

Ah, nss-myhostname is already in Debian and Ubuntu. I filed bug 1162478 to get it in main.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gnome-control-center - 1:3.6.3-0ubuntu20

gnome-control-center (1:3.6.3-0ubuntu20) raring; urgency=low

  * debian/gnome-control-center.pkla, gnome-control-center-data.install:
    - Install a .pkla to allow admins to set the hostname. This can be dropped
      when Ubuntu includes policykit >=0.106 since gnome-control-center
      ships the updated rules already (LP: #962369)
  * debian/control.in:
    - Recommend libnss-myhostname (LP: #1162475, #1162478)
  * debian/patches/62_update_translations_template.patch: Refreshed
 -- Jeremy Bicha <email address hidden> Wed, 10 Apr 2013 16:15:36 -0400

Changed in gnome-control-center (Ubuntu):
status: New → Fix Released
Jeremy Bicha (jbicha) on 2013-04-11
Changed in gnome-control-center (Ubuntu):
status: Fix Released → Triaged
description: updated
description: updated
Martin Pitt (pitti) wrote :

I believe Ryan was looking into this.

summary: - Changing hostname doesn't update /etc/hosts
+ [hostnamed] Changing hostname doesn't update /etc/hosts
Changed in systemd (Ubuntu):
assignee: nobody → Ryan Lortie (desrt)
status: New → Triaged
Changed in systemd (Debian):
status: Unknown → New
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:

tags: added: iso-testing
hackel (hackel) wrote :

This problem still exists in Ubuntu 14.04. My dmesg contains a bunch of these errors:

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

Running systemd-services 204-5ubuntu13
Also, gnome-control-center (1:3.6.3-0ubuntu54) no longer recommends libnss-myhostname as indicated in #3 above.

Changed in systemd (Ubuntu):
importance: Undecided → Low
assignee: Ryan Lortie (desrt) → nobody
Changed in systemd (Debian):
status: New → Fix Released
philinux (philcb) wrote :

Just noticed this in 64 bit 14.04 which is fully up to date.

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

Martin Pitt (pitti) wrote :

Not a bug in systemd itself; (unity|gnome)-control-center need to start depending on libnss-myhostname, like in Debian.

affects: systemd (Debian) → gnome-control-center (Debian)
affects: systemd (Ubuntu) → unity-control-center (Ubuntu)
Martin Pitt (pitti) wrote :

Actually, in the MIR bug there is still some dispute, so reassigning back to systemd for now.

affects: unity-control-center (Ubuntu) → systemd (Ubuntu)
Vincent Jaubert (0-contact-7) wrote :

Still present on 14.10

Sebastien Bacher (seb128) wrote :

That's still an issue, /etc/hosts doesn't seem to update even after installing nss-myhostname

Martin Pitt (pitti) wrote :

> /etc/hosts doesn't seem to update even after installing nss-myhostname

FTR, the purpose of nss-myhostname is *not* to update /etc/hosts, but to add itself to /etc/nsswitch.conf and dynamically resolve its own hostname (from /etc/hostname).

tags: added: rls-w-incoming
tags: added: rls-x-incoming
removed: rls-w-incoming
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in unity-control-center (Ubuntu):
status: New → Confirmed
dbstephenson (sxndave) wrote :

issue still remains in ubuntu-control-center 15.04.0+16.04.20160413-0ubuntu1

dbstephenson (sxndave) wrote :

typo above, unity-control-center

Changed in unity-control-center (Ubuntu):
importance: Undecided → Low
tags: added: zesty
Dan Cotruta (dcotruta) wrote :

I just want to add, this is not minor. If you don't update /etc/hosts then sudo hangs, which in our case breaks automation.

tags: added: rls-ee-incoming
removed: rls-x-incoming
Changed in systemd (Ubuntu Xenial):
status: New → Triaged
importance: Undecided → Low
Changed in unity-control-center (Ubuntu):
status: Confirmed → Won't Fix
Sebastien Bacher (seb128) wrote :

@Mathieu, why do you think it's a gnome-control-center issue? It just calls to hostnamed no?

I don't think it's *-control-center.

At the time, that was filed there by pitti, who correctly pointed out that something might need to depend on libnss-myhostname (from systemd) for a fallback to resolving hostname via just /etc/hostname (since /etc/hosts isn't changed). At this point though, it looks like this is no longer required.

Now, AFAICT the desktop correctly calls to systemd via dbus to ask for the change. I'll leave to you to make sure this is indeed the case (since you had commented on the bug previously, and I can't see any issues changing hostname as it is now, but maybe I'm not quite doing the same tests you were).

unity-control-center is an obvious Won't Fix for Eoan or Disco, but I'll let the Desktop Team decide whether this needs to be fixed in other releases.

Finally, this is still assigned to systemd, low priority, because hostnamed *doesn't* change /etc/hosts, and probably should (at the very least for consistency, to avoid keeping a reference to an old name for the system); but I didn't notice ill effects from not changing that file. sudo certainly doesn't hang here trying to resolve the new or old hostname.

Changed in gnome-control-center (Ubuntu):
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.