How regex domains are implemented?


First off, thanks for Pi-Hole, it's convenient and useful for many purposes.

Regex matches

We were able to write lines within /etc/hosts and manage those files with dnsmasq to block websites per-domain, but not regex matches on domains.

What's the technology (software) behind regex matches on domains?

Parent domains

And does blocking also blocks and

If not, is it possible to configure that somehow through Pi-hole?

I was using tinyproxy to block the parent domains as well.

But I think there's no proxies involved with regex matches on Pi-hole.

Thanks in advance.

Pi-hole uses regex to determine if a domain should be blocked. If you have a regex in your blacklists that matches to a domain, that domain is blocked by Pi-hole.

When Pi-hole blocks a domain (either by a domain in one of your blocklists, an exact blacklist entry, or a regex blacklist entry), it returns the NULL IP (by default) to the client.

No. Typically a regex is written for the higher level domain, and extends to domains that emanate from the higher level domain.

If you enter as a wildcard blacklist entry in Pi-hole, that will result in the following regex being generated:


This will block all three domains you listed.

root@nanopi:~# dig +short @

root@nanopi:~# dig +short @

root@nanopi:~# dig +short @

root@nanopi:~# pihole -q
 Match found in regex blacklist

If you want to block the domains and subdomains, then expand the regex to:


root@nanopi:~# dig +short @

root@nanopi:~# dig +short @

root@nanopi:~# dig +short @

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.