Running Two Pi Holes in Tandem

Reading Time: 3 minutesWhen walking and listening to the [2.5 Admins](https://2.5admins.com/) I heard about the concept of [going from treating servers as pets to treating them as cattle](https://2.5admins.com/2-5-admins-04/). They discussed the habit of giving servers functional names, rather than emotional ones. The examples were similar to DR-1 for for Disaster Recovery one, prod 1 for production one and related names.
[![The Pi Hole UI — The Pi Hole UI](http:/www.main-vision.com/richard/blog/wp-content/uploads/2023/12/Screenshot-2023-12-14-at-10.43.41-300×49.png){.alignnone}](http:/www.main-vision.com/richard/blog/wp-content/uploads/2023/12/Screenshot-2023-12-14-at-10.43.41-300×49.png)

## Servers as Cattle, Not Pets

They spoke about the legacy habit of building a server up over a period of years to the modern habit of spinning up instances and containers that can easily be replicated within minutes, independent of hardware. They spoke about the need to take notes and set up an environment once, and then destroy it, and set it up again, and to follow the notes exactly. The concept is that you don’t set something up just once, you set it up over and over, and over again, until you have the work flow perfected, and written down, for repeatability, three years down the line.

## Setting up the First Pi Hole

This week I setup a Pi-hole on a Raspberry Pi 3 and I got it to run, connected as the DNS server to block traffic that I did not want. I’m doing this as an experiment, rather than out of a burning desire not to see ads. I do think that blocking Christmas ads would be a good thing but that’s another topic.

## Setting Up the Second Pi

I don’t remember how I setup the first pi-hole but I got it working quite easily. I then repeated the process with a Raspberry Pi Zero 2 W. I downloaded the latest Ubuntu Server or Lite LTS and then ran sudo apt update and sudo apt full upgrade. I then rebooted the machine and ran the Pi hole update script and within a certain amount of time the second Pi Hole was up and running.

The router that I am using allows me to setup two DNS servers so I have the Pi as one DNS server and the Zero 2W as the second. Traffic can now go through either one with double redundancy. If one device goes down the second one jumps in, and vice versa.

I feel that rebooting the router made both Pi Holes visible to computers. Now I can see the list of queries update as devices make requests and get answers.

My inspiration for [trying the Pi Zero 2 W as a Pi Hole](https://www.youtube.com/watch?v=KBXTnrD_Zs4)

[The Raspberry Pi Tutorial](https://www.raspberrypi.com/tutorials/running-pi-hole-on-a-raspberry-pi/)

[The Pi Hole Instructions](https://github.com/pi-hole/pi-hole/#one-step-automated-install)

## Regex and Tables

Pi Holes come with a default table list that you can update every so often. You can also block specific domains either specifically, or with regular expressions. The advantage of using regular expressions is that instead of having a line for every single URL you can have regular expressions that look for specific patterns. You go from needing three million lines, to a few hundreds, if you’re really efficient. The table that comes as standard had about 141,000 items to block by default.

## Blocking Other Content

The stereotypical use for Pi Holes is to block ads but you could block porn, or gaming networks, or video sharing sites such as Tik Tok, or Social media sites and more. You could block Right Wing media sites and more. The niche that I would like is to find a way to block the hideous iOS ads when I’m playing certain games. If I could block iOS game ads I might revert to playing them again.

## Modular

There are two choices. You can use your Pi Hole, via your ISP router by telling it to use your Pi Hole as a DNS router, or you can configure your DNS settings on your mobile phone or laptop. If you’re using [Tailscale](https://tailscale.com/) or another solution you can configure your DNS settings to use the [Tailscale](https://tailscale.com/) IP address to [use your DNS server remotely via a VPN](https://docs.pi-hole.net/guides/vpn/openvpn/overview/). This could be a way of saving bandwidth when you’re surfing the web using your data plan., especially when roaming.

## And Finally

By using Pi Hole we block unwanted traffic at the DNS level, rather than the browser level. This means that we don’t need to run third party extensions in the browser. We don’t get the “If you want to use this site deactivate ad blockers, and other messages. A few years ago I blocked Twitter and Facebook using the mac’s onboard ip tables but that’s fiddly and you need to remember the name of the file that needs to be changed. With Pi Hole, once it’s setup you use an intuitive web interface. It can be used for ad blocking but it can be used to block games at work, or streaming services and more.

I would consider adding a schedule feature. Imagine that from 1900-2300 you can access netflix, YouTube and other streaming services but that the connection is blocked outside of that window. Pi Hole could have parental controls to stop access to Steam, to Nintendo and other gaming networks. It could also be used to block iOS apps to stop children from spending money on pay to win games.

I don’t know for how long I will have my two Pi Holes running in tandem. Probably until I find a new project that requires a lower spec Pi device.