Originally published at: https://pi-hole.net/2018/04/24/blocking-via-regex-now-available-in-ftldns/
We have implemented GNU Extended Regular Expressions for blocking domains into FTLDNS (as used by popular tools such as
grep -E …),
To try it, you need to be participating in the FTLDNS beta test (see here for more details). This is a new feature and we invite you to test it out but you should expect some rough edges. We would also appreciate if you could help us find any bugs or issues you run into.
Reach out to us on Discourse or Reddit with any issues you run into.
Once you’re on the beta testing branch you can configure the regex of your choice in
/etc/pihole/pihole-FTL.conf. In contrast to our already existing wildcard blocking implementation, you can now configure arbitrarily complex blocking filters with Pi-hole FTLDNS. The following regex:
will block all domains that start with “ab” (
^ab), have at least one further character (
.+) and end in “.com” (
Examples for what would be blocked by this rule:
testab.com(the domain doesn't start with "ab")
tab.test.com(the domain doesn't start with "ab")
ab.com(there is no character in between "ab" and ".com")
test.com.something(the domain doesn't end in ".com")