How to stop Network Manager (I asssume) overwriting /etc/hosts in 10.10?

Chris racerx at makeworld.com
Sun Mar 20 19:08:20 UTC 2011


On Sun, 2011-03-20 at 19:04 +0000, Chris G wrote:
> I have just upgraded from xubuntu 10.04 to xubuntu 10.10 but I think my
> problem is also in ubuntu 10.10.
> 
> Network Manager (I assume) is overwriting my /etc/hosts file every time
> I reboot my system.  My /etc/hosts file is:-
> 
>     127.0.0.1       localhost
> 
>     # The following lines are desirable for IPv6 capable hosts
>     ::1     localhost ip6-localhost ip6-loopback
>     fe00::0 ip6-localnet
>     ff00::0 ip6-mcastprefix
>     ff02::1 ip6-allnodes
>     ff02::2 ip6-allrouters
> 
> 
> ... but Network Manager (or someone) insists on changing it to:-
> 
>     127.0.0.1       chris   localhost.localdomain   localhost
>     ::1     chris   localhost6.localdomain6 localhost6
> 
>     # The following lines are desirable for IPv6 capable hosts
>     ::1     localhost ip6-localhost ip6-loopback
>     fe00::0 ip6-localnet
>     ff00::0 ip6-mcastprefix
>     ff02::1 ip6-allnodes
>     ff02::2 ip6-allrouters
> 
> Even if I make /etc/hosts read only by setting the permissions it
> *still* gets changed!
> 
> This is totally broken for me because I have a proper domain for my
> machine and another machine on my LAN provides DHCP and DNS services
> including the domain name.  With the above Network Manager changes I no
> longer have a valid domain and both apache2 and leafnode (among others)
> complain about my system not having a valid domain until I remove the
> above changes and restore my (simpler and more correct) /etc/hosts.
> 
> I believe this bug has been reported but I need a workaround to prevent
> getting screwed up every time I restart my system.
> 
> -- 
> Chris Green
> 


Simply edit /etc/dhcp3/dhclient.conf and add the following line:

# Use Google DNS Servers (add your own here)
supersede domain-name-servers 8.8.8.8, 8.8.4.4;

where <dns1-ip> & <dns2-ip> are primary dns ip and secondary dns 
ip (don't forget trailing semicolon).

This command tells dhclient to overwrite the option domain-name-servers 
value obtained from dhcp server with the values you write, thus updating
resolv.conf with the values you write in that line.


-- 
Keep well,

Chris





More information about the ubuntu-users mailing list