Update: The functionality of this is now baked into Pi-Hole! You can either add wildcarded blacklist domains on the Web Admin UI, or from the command line by running
pihole -wild example.com
Note: This works for blacklisting, but not for whitelisting. Hopefully it wont be too long until we can make this a native feature, but it needs to be perfected first! Any requests blocked in this way will not show as “Pi-holed” on the query page of the Web-Admin.
Create the file
/etc/dnsmasq.d/02-wildcards.conf, and add in your
*.domain.com etc there in this format:
xxx.xxx.xxx.xxx is your Pi-hole’s IP.
This will block all access to
What about exceptions?
For example, let’s say i’ve blacklisted
.xyz with the following in
That works, and I can no longer connect to anything on the
xyz TLD. However, I know that I want to be able to access Alphabet’s site (
https://abc.xyz). In order to do this, I can either create another file (to keep things seperate (e.g
/etc/dnsmasq.d/03-exceptions.conf) or add my exceptions to
02-wildcards.conf like so:
126.96.36.199 are your chosen upstream DNS IPs)
So, to tie it all together, the entire contents of my additional config file (the name really doesn’t matter, but they are read into
dnsmasq in alphanumerical order):
pi@raspberrypi:~ $ cat /etc/dnsmasq.d/02-wildcards.conf #Block Entire XYZ TLD address=/.xyz/192.168.1.253 #Exceptions below: #Alphabet: server=/abc.xyz/188.8.131.52 server=/abc.xyz/184.108.40.206
remember to reload and restart
sudo service dnsmasq reload
sudo service dnsmasq restart