5

In /etc/resolv.conf, I've changed the nameserver line to a new IP address. After saving and exiting, I run service network restart. I then go open /etc/resolve.conf again and see that the IP address I changed is now back to what it was prior to changing.

Why is this happening?

6

According to the RedHat 6 Documentation this is the same as with RedHat5:

Put PEERDNS=no either into the global configuration file, or into the specific interface-configuration file.

3

If you are running on Centos/RHEL edit the ifcfg configuration file and add

DNS1="xxx.xxx.xxx.xxx"
DNS2="xxx.xxx.xxx.xxx"

Then restart networking using service network restart

I know this is a very old question, I am adding my answer to help those who didn't accept the accepted answer above. Such as myself.

2

Might be you have dhcp-client in your system and it make resetting your resolv.conf file after restarting the network service.

Check in /etc/sysconfig/network or interface file whether dhcp-client protocol has defined and try to configure the static ip.

If not, you can protect your /etc/resolv.conf from being modified by anything is setting the write-protection attribute.

chattr +i /etc/resolv.conf
2

If you are using DHCP for address assignment, the cleanest way to accomplish modifying resolv.conf is to make the changes on the DHCP server side. That will in turn correctly update resolv.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.