Pi-hole, often written Pihole, is a DNS server that blocks ads and trackers for every device on your home network: when a device asks where an ad server lives, Pi-hole says it lives nowhere.
That deliberately useless answer works at the DNS level, so it covers phones, smart TVs and gadgets that could never run an ad blocker of their own.
What DNS has to do with ads
Before a device can fetch anything from the internet, it needs an IP address. A web page is rarely one request. The page itself comes from the site's domain, but its ads, analytics scripts and tracking pixels usually come from other domains, run by ad networks and analytics companies. To fetch any of them, your browser first asks a DNS server to turn each name into an address.
That lookup is the choke point Pi-hole uses. If an ad server's name never resolves to a real address, the device has nowhere to send the request, so the ad never loads. Pi-hole never has to look at the ad or the page.
How Pi-hole answers a lookup
Pi-hole is a DNS server you run on your own network. It was built for the Raspberry Pi, which gave it its name, but any small Linux machine or a Docker container will do. The project calls it a 'DNS sinkhole': unwanted lookups go in and never come back with a real answer.
Every lookup goes through the same steps:
- A device asks Pi-hole for the address of a domain.
- Pi-hole checks the name against its blocklists: lists of known ad, tracking and malware domains that you subscribe to.
- If the name is on a list, Pi-hole replies at once with
0.0.0.0, an address that leads nowhere. This is its default blocking mode. The request fails and the ad slot stays empty. - If the name isn't on a list, Pi-hole forwards the question to an upstream DNS server, such as your ISP's or a public resolver, and passes the real answer back.
- Pi-hole caches the answers it gets, so a repeat lookup of a popular domain is answered locally without asking upstream again.
Wondering how this was made? How we make these