Red Hat Bugzilla – Bug 649116
NetworkManager's updating of /etc/hosts breaks libvirtd guest DNS
Last modified: 2011-03-26 15:34:40 EDT
Created attachment 457319 [details]
avoid forcing localhost.localdomain if /etc/hosts can't be modified
Description of problem: NetworkManager sets host hostname to 127.0.0.1 in /etc/hosts while it waits for the real IP to come in via DHCP. During this time, libvirtd fires off dnsmasq, which caches the wrong (127.0.0.1) IP for the VM host's hostname. Guests' DNS lookups for the host then resolve to 127.0.0.1, even after NM has subsequently updated /etc/hosts to the VM host's DHCP-assigned IP.
Version-Release number of selected component (if applicable): NetworkManager-0.8.1-9.git20100831
How reproducible: always
Steps to Reproduce:
1. boot up VM host with NetworkManager and libvirtd
2. start VM guest
3. attempt to resolve VM host hostname from within VM guest
Actual results: VM host resolves to 127.0.0.1 on the VM guest due to dnsmasq having cached the wrong data
Expected results: VM host should resolve to the real public IP of the host
Additional info: Attempting to solve this by setting 'no-hosts' in /etc/dnsmasq.conf prevents dnsmasq from serving *other* useful data from /etc/hosts.
Also, setting /etc/hosts to immutable (chattr +i /etc/hosts) results in NetworkManager changing the VM host hostname to 'localhost.localdomain'.
May I ask that NetworkManager editing /etc/hosts be made optional ? The default could even be on, as long as those who really want to turn it of may do so ? Absent that, may I suggest the following short patch, which modifies the failure mode of being unable to modify /etc/hosts from changing the hostname to merely complaining loudly in the syslog (we're already in a failure scenario, and there are good reasons to Do Nothing rather than Do Something :) )?
*** This bug has been marked as a duplicate of bug 648725 ***