[CentOS] /etc/resolv.conf changes

Mon Mar 24 20:14:51 UTC 2008
Robert Moskowitz <rgm at htt-consult.com>

vincenzo romero wrote:
> Hello all,
>
> I'm getting frustrated attempting to understand; I googled and asked
> folks and am unable to get a straight answer.
>
> 1.  How is the /etc/resolv.conf file maintained ?  
If you are using DHCP, then the content of resolv.conf SHOULD be at the 
mercy of your DHCLIENT and the DHCP server.

In your case you are using NetworkManager, and it is getting information 
from the DHCP server to setup resolv.conf...
> I do not seem to
> get a consistent result when I save resolv.conf configuration from GUI
> or by hand using vim /etc/resolv.conf.
>   
If you do it by hand, it MAY get overwritten by NetworkManager, or NM 
may fail to change it (depends on a couple obscure DHCP items), and then 
nothing works! (been there done that at IEEE meeting last week).
> a.  Sometimes I the entries toggles between the two entries:
>
> # generated by NetworkManager, do not edit!
> ; Use a local caching nameserver controlled by NetworkManager
> nameserver 127.0.0.1
>   
This is just bad. Perhaps the DHCP server did not supply DNS resolv 
information and NM then didi 'its best'.
> b.  then when I restart the network services some the /etc/resolv.conf
> file appears like this:
> # generated by NetworkManager, do not edit!
> ; Use a local caching nameserver controlled by NetworkManager
> search lab.mycompany.com
> nameserver 192.168.17.2
>   
This is a more typical result.
> This host is:
>
> - a DNS server that is authoritative for its domain within the
> 192.168.16/20 network
>   
If it is a DNS server, then it SHOULD NOT be using DHCP to set its own 
address. You should be using static addressing.
> - I believe that even as DNS server, this host should have its
> resolv.conf file configured to define itself as a DNS server, right?
>   
So your first case is ALMOST right. resolv.conf should not point to the 
loopback address, but to the static address of the host. But if you have 
not configured NM for static addressing, well you get what you got.