Resolv.conf with two pihole servers on overlayFS

Hello,

I am setting up two Pihole server on my network on two raspberry pi 3 with static ip. I want to use overlayFS to avoid writing on the sd card and since both are on UPS, they will be pretty much running 24/7.

My router is still the gateway and the DHCP server on my whole network, and my 2 pihole servers has their IP reserved, but the pihole server does not need to query the dhcp server to boot.

My problem comes from the /etc/resolv.conf that gets both pihole server ips while I do not want them. They seem to come from the router by DHCP:

$ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver fd0f:ee:b0::1
nameserver 192.168.0.5
nameserver 192.168.0.9

I think nameserver 192.168.0.5 and nameserver 192.168.0.9 (my 2 pihole servers) should not be here. They comes from the DHCP server.

When I enable overlayFS, this file contains only that!

$ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.0.5
nameserver 192.168.0.9
nameserver fd0f:ee:b0::1

I would like resolv.conf to be exactly:

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 192.168.0.1

on both servers.

I tried to disable DHCP querying by

$ cat /etc/dnsmasq.d/10-mypiholesetup.conf
no-dhcp-interface=eth0

but that does not do the job.

Any idea on how to do it properly?

That would configure your Pi-hole's DHCP server to ignore DHCP requests arriving at its eth0 interface.

But your issue isn't Pi-hole related at all, it's a basic networking issue.

If you want a static configuration for your DNS servers, define them statically in /etc/dhcpcd.conf. Look for the lines similar to the following and add or adapt them as required:

interface eth0
        static ip_address=192.168.1.2/24
        static routers=192.168.1.1
        static domain_name_servers=127.0.0.1

You have to change IP addresses and maybe the interface to match your environment. For additional details, run man dhcpcd.conf.

Yes, that's already done, but I keep on receiving the 2 dns servers ip address from the router, even when static domain_name_servers=127.0.0.1 is defined on each one of them.

Weirly, when overlayfs is disabled, on fresh boot I have

$ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 127.0.0.1

and when I enable overlayfs (fresh boot again) I have

 cat /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.0.5
nameserver 192.168.0.9
nameserver fd0f:ee:b0::1

(which is what comes from the router).

That would suggest that your RPi is requesting DHCP over a different interface, or it's not using dhcpcd for its network configuration, or your OverlayFS is not reading the configuration from that file.

Why?.

because sd card dies and are not meant to be constantly being written on 24/7.
That's a personal choice, even if both raspberry are on an UPS, I cannot stand to loose my dns server because I did a mistake and disconnected the power plug or any other reason.

I run RPi on my home for several years, and I already lost so many sd cards over time.
It is important to have something 100% reliable, not 90% and you end up having no internet when you need the most (I am working at home now).

Invest in a reputable brand SD card and it will run for longer than the device it's in. If you've lost SD Cards then your power is not up to par, that's what kills cards. Not writes or reads. I've lost maybe 3 cards since my first Raspberry Pi (the original model) and once the firmware issue was fixed years ago it's been stable.

Of course you are free to choose to overcomplicate and spend more on other solutions, but you're causing yourself many more headaches and more points of failure this way.

ok thanks for your feedback.

the only pbl here is that overlayfs seem to have an impact on dhcp configuration

What's your mount command for overlay? Or the fstab?

I enable overlayfs by the raspi-config tool. It seems to rebuild some kind of initrd in /boot when overrlayfs is enabled.

The mount for / (overlayfs enabled) seems to be:

overlay on / type overlay (rw,noatime,lowerdir=/lower,upperdir=/upper/data,workdir=/upper/work)

The /etc/dhcpcd.conf is exactly the same (overlayfs enabled/disabled), configuring the static ip:

...

interface eth0
static ip_address=192.168.0.9/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1

but when overlayfs is enable, the /etc/resolv.conf comes from the router instead of using this config.

Check output for

ip -4 address show eth0

How does that compare with / without OverlayFS?

interestingly... eth0 does not exist when overlayfs is enabled:

  • Overlayfs on:
ifconfig
enxb827eb65acef: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
  • overlayfs off:
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

it is like if "predictable networking interface names" would be forced on overlayfs.

So I have the right behavior on overlayfs with this configuration:

interface eth0
static ip_address=192.168.0.5/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1

interface enxb827eb65acef
static ip_address=192.168.0.5/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1

A switch to predictable network names would confirm my earlier suggestion that your RPi is requesting DHCP over a different interface.

I think this can be considered a bug in the OverlayFS feature of raspi-config.

1 Like

ok thanks. Just to let you know, I have disabled overlayfs and tried log2ram as I saw in another thread. This would I hope decrease the among of writes on the sdcard. So far (this night) I had the right behavior too.

Do you know if there are other part of pihole that write to the disk, for the graph for examples? or everything is in /var/log ?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.