3

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)

WoJ
  • 543
  • 2
  • 6
  • 15

6 Answers6

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.

WoJ
  • 543
  • 2
  • 6
  • 15
2

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'

ghosts
  • 71
  • 3
1

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.

Example:

supersede domain-name-servers 127.0.0.1, ::1;
WoJ
  • 543
  • 2
  • 6
  • 15
71GA
  • 126
  • 3
0

You could just disable the service resolved by entering: sudo systemctl disable systemd-resolved.service

goldilocks
  • 60,325
  • 17
  • 117
  • 234
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.

10robinho
  • 726
  • 8
  • 17
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.

YAG
  • 101
  • 3