[CentOS] Disappearing Network Manager config scripts

Mon May 5 10:55:51 UTC 2014
Nicolas Thierry-Mieg <Nicolas.Thierry-Mieg at imag.fr>

On 05/05/2014 10:55 AM, Tony Molloy wrote:
> On Monday 05 May 2014 00:22:52 Evan Rowley wrote:
>> When I started this thread a week ago, I certainly did not expect
>>   this many replies. Without a doubt it seems Network Manager is a
>>   controversial topic. I still haven't worked out my Network Manager
>>   woes and just lost an hour troubleshooting a Golang webserver
>>   which wouldn't start.
>>
>> Apparently in Golang's net package, there is a DNS resolver
>>   function that's called whenever a server is started. That function
>>   depends on a working /etc/resolv.conf - As per usual, the
>>   /etc/resolv.conf file turned out to be the blank template
>>   NetworkManager always creates. The webserver starts now, but this
>>   /etc/resolv.conf will certainly be blown away by NetworkManager
>>   the next time the network service restarts.
>>
>> I have one idea as to why this problem persists. This file:
>>
>> ll /etc/sysconfig/network-scripts/ifcfg-eth0
>> ...
>>
>> -rw-r--r--. 1 root root    44 Apr 26 22:21 ifcfg-eth0
>>
>>
>> Is it meant to be executable? Being a configuration file, I'm
>>   assuming it doesn't need to be. Am I wrong?
>>
>
> A hack. Set up your resolv.conf as you need it.
>
> Then as root chattr +i  /etc/resolv.conf
>
> Now NM can configure the interfaces but can't change /etc/resolv.conf

indeed that's an ugly hack.

you should rather set
PERRDNS=no
DNS1=<bar>
DNS2=<foo>
in /etc/sysconfig/network-scripts/ifcfg-eth0

The options in this file are documented in:
/usr/share/doc/initscripts-*/sysconfig.txt