Configure that /etc/resolv.conf won’t be modified after restart

domain-name-systemgentooresolv.confstatic-ip

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

auto_eth0="true"
config_eth0="192.168.1.2/24"
routes_eth0="default via 192.168.1.1"
enable_ipv6_eth0="false"

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 ?

thanks!

Best Answer

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.

Add:

dns_servers="8.8.8.8 8.8.4.4"

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:

dns_domain
dns_search
dns_options
dns_sortlist