0.8.1+git.20100810t184654.ab580f4-0ubuntu2.1 breaks my /etc/hosts by attaching hostname to localhost

Bug #729091 reported by Max Bowsher
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
network-manager (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: network-manager
---
Related SRU bug is bug 659872.
---
0.8.1+git.20100810t184654.ab580f4-0ubuntu2.1 breaks my /etc/hosts by attaching my local host's hostname to localhost

It is my understanding that a machine's local host name should NOT be associated with the 127.0.0.1 or ::1 IP addresses, but rather some other address that the machine holds. The 127.0.0.1 / ::1 IP addresses should be identified as localhost / localhost6.

The recent maverick-proposed network manager has led to my machine's /etc/hosts being broken by NM, by introducing the short hostname of the machine as the first entry against 127.0.0.1 and ::1 -

127.0.0.1 altimeter localhost.localdomain localhost
::1 altimeter localhost6.localdomain6 localhost6 ip6-localhost ip6-loopback
192.168.2.180 altimeter.mxtelecom.com altimeter

Technical correctness aside, this caused my previously functioning Exim installation to start rejecting mail, because its determination of the machine's primary_hostname switched from "altimeter.mxtelecom.com" to "altimeter".

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Weird, since the whole idea is to very much avoid messing with /etc/hosts; however, the first pass when switching between the two versions may have caused this.

Also note that your hostname shouldn't be against 127.0.0.1, it is set by the installer to 127.0.1.1.

If you set it back correctly, does NM keep modifying the entry?

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

In other words, I'd really need to know what the /etc/hosts file was looking like before the updates.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Hmm, but NM has always been putting the machine's hostname as the first entry in 127.0.0.1 and ::1, so there isn't really any difference from before.

Changed in network-manager (Ubuntu):
status: New → Incomplete
description: updated
Revision history for this message
Max Bowsher (maxb) wrote :

Sorry for taking so long to revisit this.

Fortunately I use etckeeper, so I have the history of my /etc/hosts file tracked back over the last 15 months, back to what looks like initial installation of the system. (I don't remember exactly when I installed)

Looking back over it in detail, it confirms your comment #3 - NM has indeed always (wrongly) been putting the machine's hostname in as the first entry in the localhost IP addresses. What seems to have changed in this particular update is the criteria by which NM decides whether it needs to rewrite the hosts file.

It appears that on 2010-09-21 I had a fight with NM and determined that adding "localhost6" to my ::1 hosts entry would convince the NM of that time that it did not need to rewrite the file.

From that time until 2011-02-26, NM left my hosts file alone. This date is in line with the referenced SRU package being made available in maverick-proposed.

The content of my /etc/hosts file which NM@maverick-release was willing to leave alone was:

=======================================================
127.0.0.1 localhost.localdomain localhost
192.168.2.180 altimeter.mxtelecom.com altimeter

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback localhost6
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
=======================================================

NM@maverick-proposed rewrote this to:

=======================================================
127.0.0.1 altimeter localhost.localdomain localhost
::1 altimeter localhost6.localdomain6 localhost6 ip6-localhost ip6-loopback
192.168.2.180 altimeter.mxtelecom.com altimeter

# The following lines are desirable for IPv6 capable hosts
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
=======================================================

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

It seems to me like you should also have an entry 127.0.1.1 added from the installer with your hostname, similar to the one for 192.168.2.180. AFAIK there is nothing in specs saying that the hostname needs to be set to an IP the machine has (which has led us to disable NM touching /etc/hosts at all in natty).

It's obviously not quite the same if NM doesn't touch /etc/hosts at all, but this my /etc/hosts, for an example:

127.0.0.1 localhost
127.0.1.1 selene

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Perhaps we should consider backporting the entire "don't touch /etc/hosts at all" changes from upstream to Maverick, but from what I understand of your setup, that is still likely to break things. Could you please try if setting your /etc/hosts to be similar to the above (fqdn and short name on 127.0.1.1) works properly?

Revision history for this message
Max Bowsher (maxb) wrote :

Indeed, there was a 127.0.1.1 entry back in the day after the initial installation. My impression is that that is only a placeholder, and I replaced it with my machine's statically assigned rfc1918 address. Setting my fqdn and short name on 127.0.1.1 is not a sensible configuration for a machine which actually has a static IP address, since it would break TCP connections to the local host name, for example.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

I'm not sure what you mean. Surely things that connect to the host name don't care what is set in /etc/hosts, and on the contrary, local connections to local TCP ports would simply deal with lo rather than another interface.

Regardless, I'm marking this a Invalid because the discussion should really be happening in bug 659872; which I'll mark verification-failed since it breaks your setup.

Changed in network-manager (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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