Use nss-myhostname to provide default IP address of UNIX hostname

Bug #1015030 reported by Thomas Hood
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
netcfg (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Currently the installer creates this /etc/hosts for a machine named 'foo':

    127.0.0.1 localhost
    127.0.1.1 foo

If foo is connected to a LAN with domain name 'bar.com' then it's generally the case that 'foo.bar.com' resolves to the machine's external IP address. But 'foo' continues to resolve to 127.0.1.1 because nsswitch.conf contains

    hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

where 'files' is given first. Hence "ping foo" pings 127.0.1.1 but "host foo" returns the external IP address.

To eliminate this inconsistency the line

    127.0.1.1 foo

could be eliminated from /etc/hosts and the "myhostname" NSS provider (suitably modified so that it returns 127.0.1.1 for the UNIX hostname) added to nsswitch.conf at the end of the "hosts" line. That way, 127.0.1.1 is still returned for the name 'foo' but only if other methods of name resolution have failed to resolve the name 'foo'.

The Myhostname NSS provider is another fine product brought to you by supercoder Lennart Poettering.

    http://0pointer.de/lennart/projects/nss-myhostname/

Revision history for this message
Thomas Hood (jdthood) wrote :

I see that nss-myhostname has been packaged for Debian as libnss-myhostname. It's in universe.

    $ apt-cache madison libnss-myhostname
    libnss-myhostname | 0.3-4 | http://nl.archive.ubuntu.com/ubuntu/ quantal/universe amd64 Packages

It has already been patched so that it returns 127.0.1.1 rather than 127.0.0.2.

I see also that in version 0.3, nss-myhostname was enhanced such that
* it returns an external IP address if the machine has one, falling back to 127.0.1.1 if it doesn't;
* and so, in nsswitch.conf on the "hosts:" line, 'myhostname' can be listed right after 'files' so that dns doesn't have to be tried first.

I forgot to mention that this report arose out of discussion at bug #234543 which also hearkens back to Debian bug report #267321. But these are far from the only discussions about this issue.

Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in netcfg (Ubuntu):
status: New → Confirmed
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.