settings in resolv.conf are being overwritten every time I reboot my system. How can I make it to be overwritten by scrip automatically after reboot in a way I want it?
2 Answers
Make your desired change in:
/etc/resolvconf/resolv.conf.d/head
The /etc/resolv.conf
will always change upon network interface detection such as rebooting and connecting to wireless networks. Putting your configuration in the head
file will always have your configuration on the top of the list.

- 25,036
As steeldriver wrote, auto-editing the /etc/resolv.conf file is almost certainly not the right way to do what you want to do. If the system isn't automatically configuring the resolver the way you want then you should learn how the resolver and its configuration system work and make the appropriate changes to that. I once wrote another answer which may be a good place for you to start reading: How do I fix DNS resolving which doesn't work after upgrading to Ubuntu 13.10 (Saucy)
In another answer to the present question it is proposed that you add configuration lines to /etc/resolvconf/resolv.conf.d/head
. That is a quick and dirty measure that may achieve what you want. An even quicker and dirtier measure is to rm /etc/resolv.conf
and put a static file there. But in a correctly configured Ubuntu system these measures are neither necessary nor appropriate.
If you truly want to write a script to overwrite a file at boot then look at earlier answers to this question, e.g., this: How do I run a script at start up? .
dns-nameservers
field of your/etc/network/interfaces
file. – steeldriver Sep 14 '16 at 12:01