/etc/resolv.conf overwritten. Redhat/Centos

Prevent /etc/resolv.conf from being blown away by RHEL/CentOS after customizing

If you are using RHEL 6.X it may be a surprise that editing the /etc/resolv.conf will result in your changes being deleted by the OS.

This is because there is a process called NetworkManager that automatically creates /etc/resolv.conf from the settings in /etc/sysconfig/network-scripts/ifcfg-interfacename

To disable this behavior, turn off Network Manager as follows:

/etc/init.d/NetworkManager stop
/sbin/chkconfig NetworkManager off

Also in /etc/sysconfig/network-scripts/ifcfg-eth0 adjust NM_CONTROLLED to “no”.

NM_CONTROLLED="no"
DNS1=8.8.8.8
DNS2=8.8.4.4
DOMAIN=mydomain.com

Be sure to have the latest yum update as well for some issues around this.

Now you can edit your /etc/resolv.conf with custom settings like below without it being blow away:

search mydomain.com
options timeout:1
nameserver 8.8.8.8
nameserver 8.8.4.4

This entry was posted Tuesday, June 25th, 2013 at 5:29 am and is filed under Linux. Follow responses:RSS 2.0

原文地址:https://www.cnblogs.com/dracula/p/3551511.html