NetworkManager updates /etc/hosts in a way that breaks "hostname --fqdn"

Bug #663597 reported by Malte Helmert
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
network-manager (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: network-manager

Since the upgrade to maverick, my machine doesn't know it's FQDN any more:

$ hostname --fqdn
alfons
$ hostname --all-fqdns
alfons
$ python -c "import socket; print socket.getfqdn()"
localhost6.localdomain6

In all three cases, I'd be expecting the answer "alfons.informatik.uni-freiburg.de" instead, which I got before (with lucid).

I looked around a bit and found out that a change to /etc/hosts by NetworkManager is causing this.
My /etc/hosts looks like this:

    132.230.166.41 alfons # Added by NetworkManager
    127.0.0.1 localhost.localdomain localhost
    ::1 alfons localhost6.localdomain6 localhost6

    # The following lines are desirable for IPv6 capable hosts
    ::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 was modified to look like this by NetworkManager. I tried manually changing it to the following:

    127.0.0.1 localhost

    # The following lines are desirable for IPv6 capable hosts
    ::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

after which I get the expected results:

    $ hostname --fqdn
    alfons.informatik.uni-freiburg.de
    $ hostname --all-fqdn
    alfons.informatik.uni-freiburg.de
    $ python -c "import socket; print socket.getfqdn()"
    alfons.informatik.uni-freiburg.de

But unfortunately after the next reboot (or reconnect to the network), /etc/hosts is changed again and the problem returns.

Questions:
1) Is there any way to keep NetworkManager from doing this?
2) Failing that, is there any way to find out my machine's FQDN despite NetworkManager's behaviour?

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: network-manager 0.8.1+git.20100810t184654.ab580f4-0ubuntu2
ProcVersionSignature: Ubuntu 2.6.35-22.34-generic-pae 2.6.35.4
Uname: Linux 2.6.35-22-generic-pae i686
Architecture: i386
CRDA: Error: [Errno 2] No such file or directory
Date: Wed Oct 20 01:12:24 2010
Gconf:

IfupdownConfig:
 auto lo
 iface lo inet loopback
IpRoute:
 132.230.166.0/24 dev eth0 proto kernel scope link src 132.230.166.41 metric 1
 169.254.0.0/16 dev eth0 scope link metric 1000
 default via 132.230.166.254 dev eth0 proto static
IwConfig:
 lo no wireless extensions.

 eth0 no wireless extensions.
Keyfiles: Error: [Errno 2] No such file or directory
ProcEnviron:
 LC_TIME=de_DE.UTF-8
 PATH=(custom, user)
 LANG=en_US.utf8
 SHELL=/bin/bash
 LC_PAPER=de_DE.UTF-8
RfKill:

SourcePackage: network-manager
WpaSupplicantLog:

Revision history for this message
Malte Helmert (helmert) wrote :
Revision history for this message
Malte Helmert (helmert) wrote :

Looks like bug 645648 is about the same thing.

Setting /etc/domainname, as suggested there, doesn't make any difference for me.

Changed in network-manager (Ubuntu):
status: New → Opinion
Revision history for this message
Malte Helmert (helmert) wrote :

Dear Giovanni, I don't understand why this is marked as opinion.
What is the other opinion? Should I not expect hostname -f to work?
Maybe I missed a discussion elsewhere?

Revision history for this message
Malte Helmert (helmert) wrote :

No reaction? :-(

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

Right, this is not the right status for this bug. However, it is indeed the same issue as in bug 645648, so marking this as a duplicate.

Changed in network-manager (Ubuntu):
status: Opinion → New
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.