Skip to content

Instantly share code, notes, and snippets.

@agingorange
Forked from 0xmachos/multi_pihole.md
Created April 5, 2022 21:49
Show Gist options
  • Save agingorange/17958ae242c194d5690e0006f27fbf73 to your computer and use it in GitHub Desktop.
Save agingorange/17958ae242c194d5690e0006f27fbf73 to your computer and use it in GitHub Desktop.
How to configure two Pi-holes on the same network

Multiple Pi-holes

In this scenario we are configuring two Pi-holes running on the same network. pihole0 is the main DNS server while pihole1 is the secondary.

  • pihole0
    • 192.168.1.4
    • http://pi.hole0/admin/
  • pihole1
    • 192.168.1.5
    • http://pi.hole1/admin/

These IP addresses are examples, you should replace them with the static IP addresses of your devices.

Steps

There are two required steps and a third optional step:

  1. Edit /etc/hostname
  2. Edit /etc/hosts
  3. Add pihole0 as a DNS server on pihole1

Step One

Pick one Pi-hole device to be the main DNS server, this will be pihole0.

On the chosen pihole0 edit the contents of /etc/hostname to read pihole0. On the other Pi-hole device, pihole1, edit /etc/hostname to read pihole1.

Step Two

On pihole0 edit /etc/hosts. The second line should read something like 127.0.1.1 $HOSTNAME change this to read 192.168.1.4 pihole0.

On pihole1 edit /etc/hosts, change the second line to read 192.168.1.5 pihole1.

Step Three (Optional)

Go to the admin web interface of pihole1, http://pi.hole1/admin/. In Settings > DNS > Upstream DNS Servers > Add 192.168.1.4 (AKA pihole0) as a custom entry.

Why?

The main DNS server pihole0 will resolve most of the queries on the network, pihole1 should get a comparatively small number of requests. As a result pihole0 will likely have the answers to many of the requests sent to pihole1 in its cache. dnsmasq sends quries to all its configured upstream servers and uses the fastest response. If pihole0 has an answer in its cache it should be the fastest response as its on the local network. This allows us to take advantage of the larger cache maintained by pihole0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment