Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have Gentoo Linux amd64 installed on one of my computers. I have a static IP configured at /etc/conf.d/net:

routes_eth0="default via"

I manually edited /etc/resolv.conf and added google dns servers. the problem is that whenever I restart my server /etc/resolv.conf gets wiped out. I tired setting 'chmod a-w /etc/resolv.conf' and it didn't work but i actually don't really like that method anyhow.

how can I let gentoo know that I don't want /etc/resolv.conf to be modified ?


share|improve this question

5 Answers 5

The right way to do this these days is, I believe, to add the DNS information to your /etc/conf.d/net file, so that the rc scripts manage your /etc/resolv.conf file correctly.



to that file and you should be good to go. If you need other resolver settings, look at the net.example file in /usr/share/doc/openrc-*/. Some of the available settings:

share|improve this answer


chattr +i /etc/resolv.conf

If you will ever need to change resolv.conf just remove immutable flag by:

chattr -i /etc/resolv.conf
share|improve this answer
While this might prevent whatever process overwriting this file it does not really address the root of the issue. @Mat's answer seems to be the better approach. –  Bram May 20 '12 at 9:28
That's true, @Mat's approach is better. –  mzmultics May 20 '12 at 9:38

Gentoo requires that DNS configuration be added to /etc/conf.d/net in order to be retained after a reboot. Your net file would look something like this:

routes_eth0="default via"

Similarly, if you wish to specify an interface-independant DNS server (ie. this setting will apply for all interfaces) you can simply use the dns_servers directive, without appending the interface:

routes_eth0="default via"

share|improve this answer

You can add:


to your /etc/conf.d/net to prevent overwriting /etc/resolv.conf

share|improve this answer

In Debian Linux your DNS servers change after a reboot.

  1. Edit the /etc/resolv.conf file

    nameserver ...........
    nameserver ..........
    search  domainname

    save and exit.

  2. /etc/init.d/networking restart

  3. chattr +i /etc/resolv.conf

  4. Reboot system

share|improve this answer
it's working.............. –  Nitin Jun 26 '12 at 12:43

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.