Short Answer
I think the most reliable way to do that is by setting your resolv.conf
to be immutable. Once you set it the way you want, you simply run
sudo chattr +i /etc/resolv.conf
To edit it again, you need to remove the immutable flag:
sudo chattr -i /etc/resolv.conf
Alternate Answer
The application that puts that message in /etc/resolv.conf
is called resolvconf
. You can remove your resolvconf
package with (I'm assuming debian or ubuntu here, but I think resolvconf
is a debian thing):
sudo apt-get remove resolvconf
I remove it on my computers because I have found that I am more likely to be able to connect with proper /etc/resolv.conf
settings in strange situations (hotel or airport wifi, specifically) when I do not have the resolvconf
package installed. resolvconf
also does other things like DNS caching, and probably some other things I feel I can live without. You might look into what all it does before you remove it.
Important notes
Removing resolvconf
will not guarantee that your /etc/resolv.conf
remains unchanged. Other programs, like dhclient
will make edits to /etc/resolv.conf
. If you run a network manager, that might also edit /etc/resolv.conf
. I don't have much experience with network managers.
The chattr
solution should prevent those other programs from making edits, and is probably right for your server situation. If you were using it on a laptop, situations may arise where important changes to your /etc/resolv.conf
would be blocked. An example would be when accessing hotel wifi, where a modification to your /etc/resolv.conf
is needed for access to a certain locally hosted url before gain access to the proper internet). If you can remember in those situations to chattr -i /etc/resolv.conf
and reconnect to the wifi, then it shouldn't be a problem.
fgrep -r 192.168.115.147,192.178.116.168 /etc
to try to find where that specific comma-joined string came from, or look for the vendor's network configuration files (/etc/network/*
,/etc/sysconfig/network*
, etc.) to see if DHCP is set, etc.