Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
Thanks, this is exactly what I was looking for. – Lester Peabody Nov 16 '12 at 22:44

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
share|improve this answer

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

share|improve this answer

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


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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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