nss-myhostname by default
Enable nss-myhostname by default on all installations
- Name: Lennart Poettering
- Email: lennart AT poettering DOT net
- Targeted release: Fedora 16
- Last updated: 2011-08-10
- Percentage of completion: 100%
Currently if the local host name is changed /etc/hosts needs to be patched too to ensure it always stays resolvable. In order to simplify read-only root directories and to clean things up, we'll enable nss-myhostname by default. This NSS module ensures that the local hostname always stays resolvable. If any local IP addresses are configured nss-myhostname will map the hostname to them. If none are configured 127.0.0.2 resp. ::1 are mapped to it. (127.0.0.2 instead of 127.0.0.1 is used to ensure that the IP address maps forth AND back. On IPv4 127.0.0.2 is mostly equivalent to 127.0.0.1)
nss-myhostname is configured only as fallback; DNS data, or /etc/hosts always take precedence
Benefit to Fedora
Even if the hostname dynamically changes (e.g. DHCP) it is guaranteed to stay resolvable, to appease tools like "sudo" which require this.
GNOME3 will include a hostname changing UI which makes changeable hostnames more accessible to the user
/etc/hosts does not have to include host-specific information any more, and can stay read-only, thus simplifying use in stateless setups.
It's a bit nicer that the local hostname resolves to locally configured IP addresses instead of 127.0.0.1.
nss-myhostname is already in the distro. We now plan to enable it by default by pulling it in by the systemd package (which also includes systemd-hostnamed, a tiny bus service used by the GNOME3 hostname changing UI).
Anaconda and NetworkManager no longer need to write /etc/hosts, so they should drop the respective code.
How To Test
Check that sudo works in the weirdest setups still.
Try to resolve the local hostname and the local IPv4 and IPv6 addresses via "getent hosts", "getent ahosts", "getent ahostsv4" and "getent ahostsv6".
use the new GNOME3 hostname UI and play around with it, and ensure the hostname always stays resolvable.
Try all this with and without network connectivity.
If users change the hostname things should just work.
anaconda and NM should drop the code that writes to /etc/hosts.
Disable the module again, go back to editing /etc/hosts.
nss-myhostname has been around for a while and has even been in the distro for a while. Other distros even made it the default already, so it is fairly well tested. Turning it on by default should reveal very few new bugs.
- A note should be added pointing out that /etc/hosts is now static and identical on all machines.