network-admin fails to correctly edit /etc/hosts, causes sudo to fail

Bug #234111 reported by Tom Wood
2
Affects Status Importance Assigned to Milestone
gnome-system-tools (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: gnome-system-tools

Note: I have encountered these problems on each machine on which I've installed Hardy where I have a dual-NIC machine and I elect to use the eth1 as the only active NIC.

These problems occur on a freshly installed Hardy box with two NICs: eth0 is onboard and unused, eth1 is a PCI-based NIC and is the one that is connected to the LAN.

/etc/hosts immediately after the installation contains the following (ignoring the IPv6 stuff):
127.0.0.1 localhost
127.0.1.1 boxname

I am assuming that "boxname" is under 127.0.1.1 because eth1 is the active NIC. I am not sure about this.

At this point in network-manager under Connections I add the appropriate static IP address to eth1. This works as evidenced by changes made to /etc/network/interfaces and the output from ifconfig -a.

Setting the domain name under the general tab in network-admin changes /etc/hosts to the following:
127.0.0.1 localhost boxname.example.com
127.0.1.1 boxname.example.com

Any attempts at putting boxname in the hosts file using network-admin's host tab result in "boxname.example.com" being put in the file instead. Using network-admin, there is no way to add boxname as a non-FQDN name in /etc/hosts as an alias to either localhost (127.0.0.1) or boxname.example.com (127.0.1.1). I consider appending the domain name wrong in this context, in that it only appends the domain name for boxname. Any other host that I define an address for in this manner does not automatically have the domain name appended.

Attempting a sudo at this point:
sudo: unable to resolve host boxname

Any gksudo attempt hangs indefinitely.

Checking /etc/resolv.conf shows that it is correct:
domain example.com
nameserver 10.11.12.13

"hostname" returns the non-FQDN hostname.

pinging the non-FQDN hostname results in
ping: unknown host boxname

pinging boxname.example.com is successful, however. So is pinging the static IP address I assigned to eth1. I cannot ping any other machines by name or by IP address, however, even though ifconfig eth1 shows that the interface is up.

/etc/nsswitch.conf indicates that the hosts file is to be used before DNS for hostname resolution. This works only for hostnames not associated with the loopback addresses. However, pings do not work to these non-local names, even though their addresses are resolved from the hosts file.

Another interesting note: eth0 is up, even though it's not configured in my case. There's no way to switch it off (ifconfig down) with network-manager either. Unchecking "roaming mode" requires some level of configuration be done to the interface, which I don't want/need to do. I merely want it down.

My observations are that there are several issues that could be resolved simply by two things: First, assign the FQDN and it's non-FQDN both to the 127.0.0.1 loopback interface, not the 127.0.1.1. Second, any network interface should be able to be disabled via network-manager.

My fix in a previous instance for these problems was to disable the unused onboard NIC in the BIOS and fixing /etc/hosts and /etc/network/interfaces to reflect the now single-NIC (eth0) configuration. I'd rather work through a configuration fix for this without the BIOS manipulation. This would probably involve rebooting the machine into recovery mode, hand editing /etc/hosts with the non-FQDN name of the machine associated with 127.0.0.1 (not 127.0.1.1) and possibly hand editing /etc/network/interfaces to make sure that eth0 is down at boot.

--------

Just a hint to avoid manipulating BIOS:
For people suffering of not being able to sudo, you may follow this procedure:
In the network manager, General Tab, delete the Domain Name. Clicking on Tab Host saves the /etc/hosts, having the proper entry again. Open now a terminal and do "sudo bash", which opens a shell with root rights. Go back to Network Manager and put the proper domain name back, close it.
Now in the new shell, edit the /etc/hosts and delete the domain part from the 127.0.0.1 entry

Rainer

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

Tom Wood wrote:
> I am assuming that "boxname" is under 127.0.1.1 because eth1 is the active NIC.

"boxname" is under 127.0.1.1 because that is standard in Debian and Ubuntu.

If a machine has a permanent IP address then it is appropriate to assign that IP address
to the hostname, e.g.,

   123.45.67.89 boxname.foo.com boxname

> My observations are that there are several issues that could be resolved simply
> by two things: First, assign the FQDN and it's non-FQDN both to the 127.0.0.1
> loopback interface, not the 127.0.1.1.

No, that is non-standard in Debian and Ubuntu.

This:

> 127.0.0.1 localhost boxname.example.com
> 127.0.1.1 boxname.example.com

is invalid. The 127.0.0.1 should contain the hostname "localhost" and only the hostname "localhost".

Further, with that configuration the hostname "boxname" can't be resolved. It should be included as an alias.
Thus /etc/hosts should look like this in your case:

    127.0.0.1 localhost
    127.0.1.1 boxname.example.com boxname

Please see http://www.debian.org/doc/manuals/reference/ch-gateway.en.html and hosts(5).

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.