2

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
        address 192.168.0.2
        netmask 255.255.255.0
        gateway 192.168.0.254
        wpa-essid myssid
        wpa-psk mykey
        dns-nameservers 192.156.0.254

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

# Generated by resolvconf
nameserver 127.0.0.1

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
0

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
2

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
0

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.

1

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'

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.