After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 629020 - Leaves unreachable entries in /etc/hosts when stopping network
Leaves unreachable entries in /etc/hosts when stopping network
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
0.8.x
Other Linux
: Normal normal
: ---
Assigned To: Dan Williams
Dan Williams
Depends on:
Blocks:
 
 
Reported: 2010-09-08 04:59 UTC by Anders Kaseorg
Modified: 2010-10-07 06:24 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Anders Kaseorg 2010-09-08 04:59:49 UTC
NetworkManager now modifies /etc/hosts to map the system hostname to the current IP address:

18.111.118.108	balanced-tree	# Added by NetworkManager

But when stopping the network, it does not undo this modification.  This leaves the hostname pointing at a non-routable address, which breaks various applications.

(Tested with network-manager 0.8.1+git.20100810t184654.ab580f4-0ubuntu2 on Ubuntu maverick.)

See also:
https://bugzilla.redhat.com/show_bug.cgi?id=630146
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/632896
Comment 1 Dan Williams 2010-09-17 17:55:42 UTC
Is the active interface this happens with an ethernet interface, or a wifi one?

NM is set to *not* take down ethernet connections when it quits, so that you can seamlessly restart NetworkManager (for security updates and such) without blowing your network away.  In that case NM should be leaving /etc/hosts as configured before it quit.

However, if NM takes the ethernet interface completely down (by deleting the IP address and routes and killing the DHCP daemon) before it quits, yet leaves /etc/hosts with an invalid IP address, then that is a bug.
Comment 2 Anders Kaseorg 2010-09-17 18:15:25 UTC
I tested that this bug happens for both ethernet and wifi interfaces.  In both cases I explicitly told NM to disable the network before stopping it.  So yes, it does actually delete the IP address, leaving /etc/hosts with an invalid IP address:

anders@balanced-tree:~$ ping `hostname`
connect: Network is unreachable

(But, even if NM leaves the network up when exiting, the /etc/hosts modification will lead to problems as soon as the computer is rebooted.)
Comment 3 Dan Williams 2010-10-07 05:29:37 UTC
It should be fixed here:

82dd97c4b73ace6067fbe3fa92a3c7eb5a95e89b (master)
97de44c9a730fbb5a08d27e6899f7caffb015e66 (0.8.x)

If you're able to test the new code, please let me know if that fixes the problem.  Thanks!
Comment 4 Anders Kaseorg 2010-10-07 06:24:23 UTC
Thanks, that takes care of cleaning up the entries for unreachable IPs.  The other modifications to the 127.0.0.1 and ::1 entries still stick around permanently, though.  (I wouldn’t care so much about that if they didn’t have negative side effects: bug 629021.)