Question conditional forwarding

Hi there,

I have a question regarding conditional forwarding:

I'm running two pi-hole instances, simply for redundance, one of which serves as DHCP server. Both instances hold the same local copy of /etc/hosts to resolve servers with fix IP addresses.

pi-hole1 - DHCP service
pi-hole2 - no DHCP service

Now, pi-hole2 can resolve local hosts listed in /etc/hosts, but not the hosts that received a DHCP lease by pi-hole1.

To mitigate this issue, I configured conditional forwarding on pi-hole2 to pi-hole1, and pi-hole2 is now able to resolve any hosts (fix IP hosts and DHCP-configured hosts), but once pi-hole1 is not available, pi-hole2 does not even resolve the computers listed in /etc/hosts anymore.

However, from a redundance point of view, this would be very welcome. Is there any way to achieve this?

It would even be greater if both setups could run the DHCP service and both would be able to resolve all the local hosts, but this seems to be clearly beyond dnsmasq's capabilities and intentions...

Cheers
T.

How do you enter your your hosts in /etc/hosts? With hostname.domain? Or only hostname? If you specify a .domainand it is the same you use for conditional forwarding pihole2 will likely send queries for the local domain to pihole1 and ignore/etc/hosts`.

How many host do you have (fixed, DHCP)? If there are just a few you might want to checkout the "Local DNS Record" function pihole v5.0 came with. You could specify local DNS records on one pi and share with the other by copying the custom.list between them. As pihole DHCP is deterministic your devices should always get the same IP from DHCP and therefore you wouldn't have to change the entries in "Local DNS Records".

For redundancy and availability in general see here:

I like the idea of making use of /etc/pihole/custom.list.

If I had a script that populated /etc/pihole/custom.list on pi-hole2 with IPs and names of /etc/pihole/dhcp.leases on pi-hole1, the name resolution should be the same on both pi-hole instances.

Do we know if pihole-FTL needs a restart on pi-hole2 if I populate custom.list "behind its back"?

Yes.

pihole restartdns reload (pihole restartdns reload-lists might be sufficient but not sure)

pihole restartdns seems to be necessary.

If anybody intends to do the same:
custom.list needs to be provided with the FQDN of the dhcp clients. At first I had only the simple hostname added and on some DNS clients it worked, while on others it did not. Apparently, Windows, Linux and Android act differently there.
Having used the FQDN it seems to be working for all OS's now.

I used this to create a custom.list from the dhcp leases:

cat /etc/pihole/dhcp.leases | cut -d " " -f 3-4 | grep -v \*$ | sed "s/$/.your.domain/" > custom.list
1 Like

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