您的位置:首页 > 运维架构 > Linux

/etc/resolv.conf overwritten. Redhat/Centos

2014-02-16 16:26 399 查看

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: