High availability (HA) for Pi-hole (running two Pi-hole's)

Very crude but I wouldnt call it load balancing :smiley:
Nice effort though!
Here is a free load balancer (Zen) that could be used for Pi to put some logic behind the LBing like for example "Round Robin":

apt-get install git
cd /usr/local
git clone https://github.com/zevenet/zlb.git
cd /usr/local/zlb
./zlb-debian-installer.sh

Mind though "Zevenet Load Balancer installation only available for Debian Jessie, currently".
Could use two Pi's for doing the LBing (redundancy) and they could be members of your DNS farm at same time.

1 Like
  1. not equally distributed.(round robin for example)
  2. WAN DENY rules for google DNS servers (4 experiment)

any updates here? Would be perfect if we had a slave dns too

when we break it down what exactly needs to be syncd? blocklists, hosts file, whitelist, blacklist? it gets complicated trying to sync the temp. disable but for basic stuff wouldn't a crude scp transfer suffice for the interim?

Which is basically what WaLLy3K said but someone said the script they pasted did not work - did anyone else try it?

@WaLLy3K if the indenting is breaking the code is it something you can host on https://wally3k.github.io/ ?

Could you elaborate on what you mean by Nginx Load Balancer? I'm assuming most people use Pi-hole on their home networks, so it doesn't make sense to have a load balancer in front of the Pis

If it's only an issue of copying configuration between Pis, then I can try to come up with something.

A load balancer can provide HA if have two or more load balancers for redundancy that provides one virtual IP address (or more) as endpoint for the clients.
If the LB node holding the virtual IP goes down, the virtual IP will failover to a still active working LB node.
I think it will work if you take two Pi's/nodes that can do both the LBing and be members of your load balanced DNS/HTTP farm.
I noticed latest Zevenet (former Zen) is also available for Stretch now:

I really have no need for this at the moment and am too busy with other projects to try it out.
But if HA is your thing, a load balancer can come in handy for redundancy and ease of maintenance as you can take down a node at any time.

Oh thanks!

more that something balance ... I want to duplicate the synchronize the configuration

1 Like

Upvoting this feature request!

Figured I'd throw my hat in the ring here. I also run pihole at home and currently run redundant instances but managing them both is kind of a pain. It would be nice to have one interface that can control/get stats from/etc both(or more) of them. If I need to whitelist or blacklist something I have to do it in two places, if I need to disable it temporarily I have to do it in two places, etc. It would be real nice to be able to manage multiple pihole's from one place.

2 Likes

I'm gonna try this out. i already have an nginx instance for reverse proxy remote access for all my docker containers.

1 Like

Hey, setting up load balancing is quite easy, but keeping to piholes in sync is not easy. is there anywhere a description which files need to be synced and if a sync runs, does pihole need to be restarted? moreover i already have two dhcp servers on my samba dcs in failover mode (isc-dchp). Is there any chance to cluster the pihole built in dhcp server

It's mentioned in this topic : High availability (HA) for Pi-hole (running two Pi-hole's) - #2 by WaLLy3K

Samba DCs as in Active Directory ?!
I am sure there is some DNS forwarding option like Windows has :

HA for pi-hole's is an interesting idea but I have to add that if you want robust HA and synchronization it might be time to level up and go for pfsense and pfblockerng. It might be more dynamite than most people in this thread really want, but for a few cases I see here, it's probably a good path to consider.

If you just want Pi Hole responding faster, I'm running it on both a Pi 3b+ and an Asus Tinkerboard. The path of least resistance to making Pi Hole run faster is the Tinkerboard as it has a proper NIC without a USB backend, a faster CPU and faster onboard eMMC storage. And it fits all your existing cases for a Pi. Every aspect of the Pi Hole is substantially faster on the tinkerboard.

If you still want to run multiple Pi's for redundancy, have a primary and secondary - and rsync the config from the primary? I haven't tried this, but it seems like this should work.

What speed differences are you seeing in DNS resolution between the Pi and the Asus?

My experience from a cursory scan of query log on two wireless Pi's - typical DNS query being resolved in 10-20 msecs on a Pi-3B+ or 20-30 msecs on a Zero. I compared those two because they are both on third party DNS. I have another Pi-3B+, wired running unbound and a lot more data is cached in that configuration, so it's a few tenths of a msec for most.

I can't see any noticeable difference on the client end from any of these Pi's.

Cached? I assume cached is reasonably close to a somewhat decent comparison here - Client on Wifi - Asus on Wire. .1ms for cached.
2018-09-22 19:11:18 A speedtest.network.utexas.edu localhost OK (cached) IP (0.1ms)

A local comparison is out of reach at the moment, the Pi 3B+ I was speaking of is on a family members network. I'd intended to put in a reverse ssh tunnel on that guy but did not. I can bring one up locally though for an A/B comparison in the next few days. speedtest-cli will hit full gig speeds on a gig wan from the Asus - so, it's at least not limited at the NIC.

Any way you look at it, the Pi is fast enough here, all I'm saying is 1%'ers looking to eek out the limits could see this as an easier option to clustering. The Tinkerboard is annoying AF b/c their images assume you will have HDMI display, mouse and keyboard to bring the board up! Other than that, it seems like a good piece of gear.

Running two piholes currently for redundancy, would be super cool for them to have a sync feature for whitelist/blackist. This is so I dont have to keep mimicking my changes on each one. Querying both would at the same time would be great too.

Here is a sync setup from a Reddit poster.

https://www.reddit.com/r/pihole/comments/9hi5ls/dual_pihole_sync_20/

1 Like

Running Pi-hole on HOST and in VM also, great! :slight_smile:

After more time running the Tinkerboard with Pi Hole I've decided the Tinkerboard is a complete piece of junk and I would much rather have two Pi's for the same price.

this is a great feature request and I look forward to have it implemented directly on the UI