I use a static IP for my RPi:

root@rpi2:/etc# cat /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug wlan0
iface wlan0 inet static
        wpa-essid myssid
        wpa-psk mykey

/etc/resolv.conf (which is a plain file, not a link) gets rewritten at each reboot with

# Generated by resolvconf

I do not even have resolvconf installed!

root@rpi2:~# aptitude search resolvconf
p   resolvconf  - name server information handler

How can I disable this overwriting? (short of chattr +i which is an ugly hack)

  • I'm still confused by what exactly the thing is (the old method appears to mostly works for me...), but apparently there is some new way to configure the internet, see here. Which version of raspbian are you using?
    – Wilf
    Dec 1 '15 at 13:58
  • @Wilf: this is interesting - I saw both ways but did not know that the supplicant one is the way to go forward. As for my question, please see my answer - I found the issue (which is IMHO a bug)
    – WoJ
    Dec 1 '15 at 14:02

Open /etc/dhcp/dhclient.conf and input a line starting with supersede. This line makes sure that only the supplied list of values for domain-name-servers on it's right will be written inside /etc/resolv.conf when writing event happens.


supersede domain-name-servers, ::1;
  • This doesn't work on all RPI's... I wonder why?
    – 71GA
    Feb 23 at 19:09
  • 1
    If this method does not work first edit the /etc/resolv.conf and dissable insert into a file using this command: chattr -V +i /etc/resolv.conf. To revert back use the command: chattr -i /etc/resolv.conf. (stackoverflow.com/questions/28860655/…)
    – 71GA
    Feb 23 at 19:34

It looks like I found the issue. /bin/dhcpcd was still running despite no interfaces being configured via DHCP. The culprit is dhcpcd5.

Removing the package helped (and, surprise, something called openresolv was included)

root@rpi2:~# aptitude purge dhcpcd5
The following packages will be REMOVED:
  dhcpcd5{p} openresolv{u}

/etc/resolv.conf is not overwritten anymore.

  • 1
    With respect this is like solving a rattling noise problem in a car by removing the spare. dhcpcd is included in all recent releases of Raspbian, and removing it will break other features. If you don't want to use it you should disable in systemd. There is nothing wrong with configuring your Pi the old way, but you can set static with dhcpcd.
    – Milliways
    Dec 1 '15 at 22:14
  • @Milliways: could you please elaborate on break other features? dhcpd was installed on my system but a dhcpd.conf was not even present.
    – WoJ
    Dec 2 '15 at 7:23
  • 1
    dhcpcd is a complex program, and not without its problems. I think the Foundation adopted it because it automates networking (particularly WiFi) and allows easy setup from GUI. (Current GUI WiFi setup requires it.) I was initially not keen, but the fact that it allows zeroconf over link-local and thus ssh is a plus. It automatically handles changing network conditions without the complexity of wpa-roam. Lastly it is highly configurable, even if the documentation is a bit cryptic and technical. See the following for overview and read the man. wiki.archlinux.org/index.php/Dhcpcd
    – Milliways
    Dec 2 '15 at 7:52

Instead of removing dhcpcd and breaking a bunch of stuff, you could configure /etc/dhcpcd.conf (and probably /etc/init.d/dnsmasq) with your DNS information...

Just sayin'

  • On my setup of Raspbian GNU/Linux 10, adding the line resolvconf=NO to the file /etc/resolvconf.conf fixed this issue for me. Feb 1 at 0:13

It may be simple as putting it's permissions to read-only.

sudo chmod 440 /etc/resolv.conf

But I would suggest to check again what is causing your resolv.conf to be overwritten as setting it to read-only may cause some other unexpected things.

  • But I would suggest to check again what is causing your resolv.conf to be overwritten - this is the essence of my question :)
    – WoJ
    Dec 1 '15 at 13:50

I found this similar question for Unix. The solution does not require to remove the dhcpd5 package.

However, I have not yet figured out where the config files for dhcpd are hiding on my Pi/Jessie. There are several suggestions here, I'll try the one where you add fixed DNS addresses at the end of the /etc/dhcpcd.conf.

Will keep you posted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.