Skip to content

Instantly share code, notes, and snippets.

@0xmachos
Created June 15, 2018 12:44
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save 0xmachos/7668504b7238e799255db762f8f450b0 to your computer and use it in GitHub Desktop.
Save 0xmachos/7668504b7238e799255db762f8f450b0 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.

@flyerbear
Copy link

This is probably a stupid question, but how do I initially change the URL of each pi hole so that "http://pi.hole0/admin" goes to my primary and "http://pi.hole1/admin" goes to my secondary?

@chexsum
Copy link

chexsum commented Jan 5, 2023

Bit late but youd want to run pihole -r and choosing reconfigure on both if youre changing hostnames

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