What is Pi-hole?
Pi-hole is a DNS sinkhole that protects your devices from unwanted content, without installing any client-side software?
In other words, it’s a piece of software that can help block ads, malicious sites at the router level through blocklists.
If you’re interested in how to install pi-hole, you can follow this tutorial:
https://docs.pi-hole.net/main/basic-install/
High Availability Pi-Hole
When it comes to DNS, typically you would setup a primary and secondary unit by pointing all your traffic to two different sources. With the aid of a add-on called gravity sync, this is now possible for a pi-hole setup (sort of).
Gravity Sync is an easy way to keep multiple pi-holes in-sync. Remember a Pi-hole uses blocklists in order to block ads and unwanted sites. If you would like to use more than one pi-hole in your environment that would mean you would need a method to keep the blocklist and database in-sync with each other.
Gravity Sync
Gravity Sync
https://github.com/vmstan/gravity-sync
System Requirements
Gravity Sync requires two Pi-hole instances running on two separate hosts.
Other packages needed:
- Git
- Open SSH
- Rsync
- Sudo
As of this post, these are the operating systems compatible with Pi-hole.
Installation
Before installing gravity sync, make sure you have a backup of your pi-hole configuration just in case anything goes wrong.
This can be accomplished by going to:
Settings > Teleporter > Backup
After making a backup, installing gravity sync is as simple as open an SSH session to each Pi-hole, and execute the following script.
curl -sSL https://gravity.vmstan.com |bash
The configuration utility will guide you through the process of:
- Specifying the IP address of the remote Pi-hole instance.
- Specifying the SSH username to connect to your remote Pi-hole host.
- Creating a unique key and pairing it to your remote Pi-hole.
- Providing details about how each of your two Pi-hole are configured.
Automating the Process
After installing and configuring Gravity Sync, there is one last thing you need to do so you can set it and forget it.
Gravity Sync allows you to automate how often your secondary pi-hole should be updated. This is handy especially if you are setting this up on a Raspberry Pi or any device that you are doing constant read/writes to and SD card.
The commands are as follows for automation:
- gravity-sync auto – 5 min intervals
- gravity-sync auto hour – hourly intervals.
- gravity-sync auto half – half-hour intervals.
- gravity-sync auto quad – quarter-hour intervals.
Updating Gravity Sync
Like all pieces of software, it’s a good idea to keep it up-to-date. Updates are handled with the following commands:
- gravity-sync version
- gravity-sync update
Conclusion
This was a simple and easy exercise on how to have a high available pi-hole setup. For additional information, visit: https://github.com/vmstan/gravity-sync