1

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?

Teck
  • 13
  • 2
    What exactly are you trying to do? Whatever it is, auto-editing the /etc/resolv.conf file is almost certainly NOT the right way to do it – steeldriver Sep 14 '16 at 11:55
  • I just want to setup my own nameservers, every time i do it there it gets overwritten. – Teck Sep 14 '16 at 11:57
  • 3
    If you're using a Desktop system, then you should be setting those in the GUI (after changing the IPv4 settings from "Automatic (DHCP)" to "Automatic (DHCP) addresses only" (or "Manual" if you want static IP addresses instead of DHCP). On a server, you would add them via the dns-nameservers field of your /etc/network/interfaces file. – steeldriver Sep 14 '16 at 12:01

2 Answers2

0

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.

L. D. James
  • 25,036
0

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? .

jdthood
  • 12,467