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!
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:
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:Try:
If you will ever need to change resolv.conf just remove immutable flag by:
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: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:You can add:
to your
/etc/conf.d/net
to prevent overwriting/etc/resolv.conf
In Debian Linux your DNS servers change after a reboot.
Edit the
/etc/resolv.conf
filesave and exit.
/etc/init.d/networking restart
chattr +i /etc/resolv.conf
Reboot system