What Is Pi-Hole?
Pi-hole is open source software that acts as a DNS sinkhole to protect your devices from unwanted content, without the need for any client-side software like apps or browser plug-ins. Put simply, Pi-hole acts as a mini DNS server that blocks your devices from looking up the internet addresses of advertising servers, so they can’t serve the ads. This way, it blocks ads not only in browsers, but also mobile apps and smart TVs — and it makes your network faster! We call it a “black hole” for internet advertisements.
What Is DNS?
At a very basic level DNS (Domain Name System) is like a phone book for domain names on the internet. It’s what your computer uses to translate hostnames (e.g. pi-hole.net) to IP addresses (in this case, 188.8.131.52). A request for an IP address is usually sent to an upstream DNS server (e.g., Google’s 184.108.40.206).
How Does Pi-Hole Block Ads?
Pi-hole sits on your network in the middle of your computer and the upstream DNS server.
When Pi-hole receives a DNS request, it checks whether the domain exists on its blacklist, and if so, it returns the address 0.0.0.0, which is DNS-speak for “This number has not been recognized, please check the number and try again.”
If the domain is not on Pi-hole’s blacklist, then the request will be forwarded to the upstream DNS server, and the actual IP address will be returned to the client, your device.
What Else Can I Block?
Pi-hole was designed to block known ad-serving domains, but really any domain can be added to its blacklist, and it will have the effect of the content not being served to the requesting client. So you can block known malware sites and other odious domains. We can think of a few.
Set Up Your Pi-Hole
Pi-hole can be installed on any hardware with a supported operating system (docs.pi-hole.net/main/prerequisites), although most commonly it is installed on a Raspberry Pi. Even a Pi Zero (Figure A) will do!
Oh, the Things You Can Block
Pi-hole v5.0 was released in May 2020 with new features such as per-client blocking (choose which block lists to apply to which devices) and deep CNAME inspection to prevent domains being masked. And in v5.1 released in July, we added Dark Mode!
Pi-hole Away From Home
Pi-hole can also block ads to your mobile devices when you’re away from home. By pairing your Pi-hole with a VPN to tunnel back to your network, you can have ad blocking on your cellular devices, helping with limited bandwidth data plans. Learn more at docs.pi-hole.net/guides/vpn/overview.
Watch Me Block It
A satisfying way to extend this project is to add a display right on the Pi. Adafruit built a Pi-hole with a tiny monochrome OLED or mini color TFT (learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w) to display the number of ads blocked, DNS queries handled, and client devices benefiting from the blockage (Figure E). Later they upgraded the project (learn.adafruit.com/pi-hole-ad-pitft-tft-detection-display) with a bigger 3.5″ color TFT and PADD client software (github.com/jpmck/PADD) that displays way more information (Figure F), including total domains blocked, total queries Pi-holed, and top offending ad domain.