This is a custom regex filter file for use with Pi-hole v4+ (FTLDNS).
There is also an optional regex filter for Facebook which will be separate to the installer and each entry will need to be added manually.
All commands will need to be entered via Terminal (PuTTY or your SSH client of choice) after logging in.
The installer will determine whether you are using the Pi-hole database or the older style regex.list, then evaluate your current regular expressions and act accordingly. It has been created to make life easier.
This script requires Python 3.6+ in order to run correctly. It has been written and tested for Raspbian Buster and Ubuntu Server.
If you experience syntax errors due to the use of f-strings, this is likely because your installed version of Python is below 3.6.
At the time of the scripts creation, it is necessary to run as root in order to modify files in /etc/pihole
(regex.list
and gravity.db
)
Yes, you can. You can enter them one by one in the Pi-hole web interface.
If you are using the new Pi-hole DB
sudo cp /etc/pihole/gravity.db /etc/pihole/gravity.db.bak
If you are using the older style regex.list:
sudo cp /etc/pihole/regex.list /etc/pihole/regex.list.bak
curl -sSl https://raw.githubusercontent.com/mmotti/pihole-regex/master/install.py | sudo python3
The following instructions will create a cron job to run each morning at 02:45 (adjust the time to suit your needs):
-
Edit the root user's crontab (
sudo crontab -u root -e
) -
Enter the following:
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
45 2 * * * /usr/bin/curl -sSl https://raw.githubusercontent.com/mmotti/pihole-regex/master/install.py | /usr/bin/python3
- Save changes
curl -sSl https://raw.githubusercontent.com/mmotti/pihole-regex/master/uninstall.py | sudo python3
If this script is the only thing you've added to the root user's crontab, you can run:
sudo crontab -u root -r
Otherwise, run:
sudo crontab -u root -e
and remove the three lines listed above in the install instructions.