GNOME Bugzilla – Bug 629020
Leaves unreachable entries in /etc/hosts when stopping network
Last modified: 2010-10-07 06:24:23 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
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.
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.)
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!
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.)