What is Pi-Hole? #
Pi-hole is a network adblocker for your devices. By configuring your Raspberry Pi as a DNS Sinkhole.
How does it work? #
Pi-Hole operates at the network layer in reference to the OSI model. It blocks unwanted content via IPv4 and IPv6.
All DNS queries get sent to the Sinkhole to be filtered out, if the domain is not blacklisted then it gets forwarded to a real DNS server to be resolved.
Installation #
To install, I followed the documentation guide here.
Configuration #
Once install is complete you can login using the web interface.
Here, you can view query logs and specify which websites you want to block.
Experimentation #
I wanted Pi-hole primarily to block YouTube Ads for my phone and TVs.
Here is the log of some DNS queries while using YouTube
We can try to sort out which domains look ad related, but we need to be careful. Because picking the wrong domain could break the YouTube website. Ads share the same domain as the actually video content, so Pi-Hole can not work all time.
As of now I am currently working on a RegEx filter to block this subdomain rr1---sn-o097znze.googlevideo.com
which I think is related to Ads on YouTube. I am using regex101.com to test and debug, but as of now it is not currently working… I will need to do some more reading and troubleshooting. This is the RegEx filter that I have right now/^rr[0-9]---sn-[a-zA-Z0-9]{8}\.googlevideo\.com$/gm
.
Conclusion #
Pi-hole was a excellent way to learn a little bit about DNS and networking. It serves as a good adblocker for devices such as smart phones/tvs.
I will try to work on blocking more ad domains on YouTube via RegEx filtering. So, I will update this post when I get that figured out… 😀