ipv6 /etc/hosts missing localhost hostname

Bug #301430 reported by Robb Topolski
270
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubiquity
Invalid
Undecided
Unassigned
netbase (Ubuntu)
Fix Released
Undecided
Unassigned
ubiquity (Ubuntu)
Fix Released
Medium
Colin Watson

Bug Description

Binary package hint: netbase

ipv6 /etc/hosts is missing the "localhost" hostname

#1: (How Discovered) Intrepid installed. In a case where a program could not find its server on ipv4 localhost, it queried for ipv6 localhost. A DNS AAAA query for "localhost" was subsequently seen going to the external DNS server instead of being resolved on the machine. When localhost was added to the ipv6 section of /etc/hosts, the external query was not made (and an associated blocking delay disappeared). (This is not a duplicate of bug 274995, but was exposed by it.)

#2: A fresh install of netbase_4.32ubuntu1 (intrepid) leaves /etc/hosts with this ipv6 section
 ::1 ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters
 ff02::3 ip6-allhosts

However, the update_hosts_file() in the netbase.postinst script in that package indicates that section ought to look like this:
 ::1 localhost ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters
 ff02::3 ip6-allhosts

(It is important to note that the update_hosts_file() function adds to /etc/hosts only if "::1" is not found. It will not update the hosts file if the word "localhost" is missing from an existing line.)

#3: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=427067 also clearly indicates intention. Mentioned in that report, a useful message at http://www.ietf.org/mail-archive/web/dnsop/current/msg05542.html which is not authoritative to any specific implementation, but suggests that localhost should be listed for consistency. (Furthermore, http://www.ietf.org/mail-archive/web/dnsop/current/msg05541.html suggests a possible misplaced intention for those who decided to not include localhost for ::1 was to avoid breaking legacy software. This is very plausible, as search engines easily reveal a great deal of examples of legacy software having difficultly when ipv6 is present.)

SEVERITY/PRIORITY/SECURITY CONSIDERATIONS: If a rouge DNS server answers a AAAA request for localhost with an IP address, it could redirect output for the affected purpose at worst or externally expose the existence of certain services at least. Otherwise, a properly formed /etc/hosts file is foundational/fundamental for network hosts -- changing it either way may have an impact. If a change ought to be made, it ought to be made quickly as users and developers are transitioning to IPv6 or will be in short order. They more time they have to find and fix bugs, the better.

Revision history for this message
Steve Langasek (vorlon) wrote :

The /etc/hosts file in an installed system is generated by netcfg. The version of netcfg in Intrepid, 1.44ubuntu4, specifically does add an ipv6 localhost entry. Here are the entries it creates:

  ::1 localhost ip6-localhost ip6-loopback
  fe00::0 ip6-localnet
  ff00::0 ip6-mcastprefix
  ff02::1 ip6-allnodes
  ff02::2 ip6-allrouters
  ff02::3 ip6-allhosts

What was in your /etc/hosts, if not this?

Changed in netbase:
status: New → Incomplete
Revision history for this message
Robb Topolski (funchords) wrote :

Hi Steve,

I'm glad you identified the right package. It was difficult for me to figure out what actually initially creates /etc/hosts!

 > What was in your /etc/hosts, if not this?

Exactly what you posted, except for the localhost entry in the ::1 line. This condition is common across two fresh installs here at home.

----
127.0.0.1 localhost
127.0.1.1 topol015

# 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
ff02::3 ip6-allhosts
----

Also, hopefully helpful ...

 - My installs were from the Live CD Gnome desktop Live User environment (I did not install from the CD without booting up the Gnome session first).
 - My installs were on a SOHO LAN with an IPv4 router that was also the DNS server and was not responding to IPv6 DNS queries (in case netcfg or some other tool makes choices based on IPv6 reachability)

However,
 - Dovel mentioned in https://bugs.launchpad.net/ubuntu/+source/alsa-utils/+bug/274995/comments/230 that neither his upgraded installation contained the correct /etc/hosts line, nor did his installation direct from CD. (His upgraded installation may have had a different audio configuration or some other factor, it did not experience the delay in 274995.)

(If I understand it correctly,) The bug in 274995 (a condition with a delay noticed by a large number of users) involves attempts to reach a user-session Pulseaudio daemon during /etc/init.d/alsa-tools stop. Of course, the daemon had shut down with the end of the user session, but the alsa-tools seemed oblivious to that and still treated them as part of the default audio system. To experience the delay, there had to be no IPv6 localhost in /etc/hosts AND ALSO no timely response to the resulting AAAA DNS queries for localhost. This is an indicator that the number of users without localhost for ipv6 in /etc/hosts may be quite high.

Revision history for this message
Laurent GUERBY (laurent-guerby) wrote :

I confirm after an upgrade I didn't have localhost on the ::1 line and after 274995 fix I still have shutdown delay. Will try your change tomorrow.

Out of curiosity, after a fresh install what is the expected /etc/hosts IPv4 section?

Revision history for this message
Robb Topolski (funchords) wrote :
Revision history for this message
Kevin Hausmann (salema) wrote :

I had the incomplete line in /etc/hosts as well (intrepid upgraded from hardy). Anyway, the update of alsa-utils fixed the shutdown hang for me (I added the missing "localhost" to /etc/hosts anyway).

Revision history for this message
Michael (michaeljt) wrote :

I have this issue. Robb Topolski requested in bug 274995 to report it here. This system was initially installed as Kubuntu 7.10, and was upgraded to 8.04 and 8.10 and then switched to Ubuntu without K.

Revision history for this message
mal (mjw-email) wrote :

I have this issue. Robb Topolski requested in bug 274995 to report it here. System was a clean install of Intrepid.

Revision history for this message
quantumphaze (quantumphazor) wrote :

Yep, it's broken here too

----
127.0.0.1 localhost
127.0.1.1 3680
192.168.0.25 serv

# 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
ff02::3 ip6-allhosts
----

Note: serv is my toy server and I added it manually.

Should I change it manually to the correct line? (I'm going to do it anyway, but is it the right way to do things?)

Revision history for this message
JQ (bazs111) wrote :

intrepid upgraded from hardy has the incomplete line in /etc/hosts
--- clip ---
$ cat /etc/issue;fgrep localhost /etc/hosts
Ubuntu 8.10 \n \l

127.0.0.1 localhost
::1 ip6-localhost ip6-loopback
--- clip ---

Revision history for this message
Robb Topolski (funchords) wrote :

question answered, several examples provided

Changed in netcfg:
status: Incomplete → Confirmed
Revision history for this message
Robb Topolski (funchords) wrote :

I think this bug lives in ubuntu-installer/ubiquity/
currently line 1525 /scripts/install.py (revision 2954)

1515 hosts = open(os.path.join(self.target, 'etc/hosts'), 'w')
1516 997 print >>hosts, "127.0.0.1\tlocalhost"
1517 1772 if domain:
1518 print >>hosts, "127.0.1.1\t%s.%s\t%s" % (hostname, domain,
1519 hostname)
1520 else:
1521 print >>hosts, "127.0.1.1\t%s" % hostname
1522 997 print >>hosts, textwrap.dedent("""\
1523 996
1524 997 # The following lines are desirable for IPv6 capable hosts
1525 ::1 ip6-localhost ip6-loopback
1526 fe00::0 ip6-localnet
1527 ff00::0 ip6-mcastprefix
1528 ff02::1 ip6-allnodes
1529 ff02::2 ip6-allrouters
1530 ff02::3 ip6-allhosts""")
1531 996 hosts.close()

Revision history for this message
cevatcethun (cevatceyhun) wrote :

Same here. I've installed 8.10 from boot and immediately applied all updates available (not proposed ones).

===================================
127.0.0.1 localhost
127.0.1.1 NEWTON

# 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
ff02::3 ip6-allhosts
===================================

Revision history for this message
Robb Topolski (funchords) wrote :

Proposed change for ubiquity/scripts/install.py -- I am not on the dev team so someone needs to review/sponsor this change. This would solve the issue for future new installs. This does not solve the issue for the currently installed base.

=== modified file 'scripts/install.py'
--- scripts/install.py 2008-10-30 17:34:58 +0000
+++ scripts/install.py 2008-12-09 16:58:04 +0000
@@ -1522,7 +1522,7 @@
         print >>hosts, textwrap.dedent("""\

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

Revision history for this message
Steve Langasek (vorlon) wrote :

and netbase is the right package to fix this in upgrades for installed systems, so reassigning back from netcfg to netbase.

Changed in ubiquity:
status: New → Confirmed
Changed in netbase:
status: Confirmed → Triaged
Changed in ubiquity:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Bob/Paul (ubuntu-launchpad-bobpaul) wrote :

My host file was incorrectly configured. I upgraded to Intrepid during the beta period using the update-manager. I'm not sure if it was correctly configured in hardy. I just stumbled upon this bug and checked my configuration.

Revision history for this message
Colin Watson (cjwatson) wrote :

(We don't use the upstream ubiquity project for bug reports. The Ubuntu ubiquity task remains open and is the right place for this bug.)

Changed in ubiquity:
status: Confirmed → Invalid
Revision history for this message
Colin Watson (cjwatson) wrote :

Sorry we overlooked this change to netcfg. I've committed the obvious change to sync up ubiquity with it now, for our next upload to Jaunty.

Changed in ubiquity (Ubuntu):
assignee: nobody → cjwatson
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubiquity - 1.12.3

---------------
ubiquity (1.12.3) jaunty; urgency=low

  * Sync with netcfg 1.44: Define IPv6 ::1 address as "localhost" (thanks,
    Robb Topolski; LP: #301430).
  * Silently skip non-existent devices in /proc/swaps (LP: #290947).
  * Use small print rather than italics in "Who are you?" (LP: #287626).
  * Revert r2984 from ubiquity 1.11.5, and instead filter out language packs
    that don't exist in the live filesystem's apt cache; this allows us to
    accurately produce incomplete language support notifications again.
    Thanks to Mario Limonciello for testing (LP: #337748).
  * Mythbuntu frontend:
    - Don't crash if --no-migration-assistant was used (LP: #354368).
  * Automatic update of included source packages: partman-base 129ubuntu6.

 -- Colin Watson <email address hidden> Fri, 03 Apr 2009 23:39:10 +0100

Changed in ubiquity (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This looks to be fixed in 11.04.

Changed in netbase (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

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