GNOME Bugzilla – Bug 632157
[enh] add custom aliases to default IP address mapping lines
Last modified: 2010-12-17 04:48:17 UTC
I develop several web sites on my laptop, and each one is a different virtual host through Apache. Until Lucid, I was able to alias these hosts in /etc/hosts, like this 127.0.0.1 localhost localhost.localdomain myhost1.localdomain myhost2.localdomain myhost3.localdomain Starting with Maverick, however, NetworkManager overwrites the 127.0.0.1 line every time it initiates a new network connection, so these aliases are lost. It is fair to argue that aliasing 127.0.0.1 isn't ideal, but as far as I can find, NetworkManager doesn't offer any alternative for aliasing the bound IP address. For example, if I connect to WiFi, it adds a line like 192.168.0.101 snape There seems to be no way to get it to do 192.168.0.101 snape myhost1.localdomain myhost2.localdomain myhost3.localdomain NetworkManager should not overwrite the 127.0.0.1 line in /etc/hosts until there is an alternative method available for aliasing on the local machine, without setting up an entire local DNS server. Also tried using 127.0.0.2, etc., but NM overwrites those as well. (Note: also logged downstream for Ubuntu 10.10 at https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/659872)
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 514580 ***
Actually these days NM *does* touch /etc/hosts because we need to ensure that the current machine hostname maps to either 127.0.0.1 or the current IP address of the machine. Reopening.
A fix for overwriting custom mappings on localhost lines was committed about two weeks ago: commit ee9ce6027b3fc0cb4aa14442ef8b628b80b726eb commit bbf3f12d7b2c79c49d87d41e6cf7b65ac7782071 But NM will not yet add the custom names to the public IP address mapping lines, thus marking this as an enhancement.
Note that you *should* be able to add custom entries below the 127.0.0.1/::1 lines with any IP address you want, and any aliases you want. If NM touches those aliases, then that's a bug. NM only cares about the 127.0.0.1/::1 entries, and any entry with "# Added by NetworkManager" at the end. So that's a workaround.
Note that we're going to remove the /etc/hosts editing functionality from NetworkManager since it's causing too many problems. After that you'll be able to modify /etc/hosts however you like, and NM won't touch it.