Setting Up Pi-hole for Network-Wide Ad Blocking
Pi-hole is a network-wide ad blocker. It sits between your devices and the internet, swallowing DNS requests for known ad domains before they ever reach your browser. The result: no ads on any device on your network, without installing extensions on each one.
Here's how to get it running on a Raspberry Pi.
What you'll need
- A Raspberry Pi (any model, even a Zero will do)
- A microSD card (8GB+)
- Your router's admin credentials
- A few minutes
Step 1: Install Pi-hole
Get your Pi running Raspberry Pi OS, SSH in, and run:
curl -sSL https://install.pi-hole.net | bashThe installer wizard will ask about network interfaces and upstream DNS providers. The defaults are sensible, just go with them if you're unsure.
At the end you'll get an IP address and admin password. Write them down.
Step 2: Point your router at it
Log into your router's admin panel (usually 192.168.0.1 or 192.168.1.1), find the DNS settings (often hiding under DHCP or Network Settings), and change the primary DNS server to your Pi's IP address.
Save, reboot the router, and that's the core setup done. Every device on your network now has its DNS queries filtered through Pi-hole.
Step 3: Custom domain names (bonus)
This is a nice trick. You can make your Pi-hole respond to custom domain names on your local network.
- Open the Pi-hole web interface at
http://<pi-ip>/adminand log in - Go to Settings > DNS
- Set your local domain name (e.g.
home.lan) - SSH into the Pi and edit the config:
sudo nano /etc/dnsmasq.d/01-pihole.conf- Add a line to assign a hostname to a device by MAC address:
dhcp-host=AA:BB:CC:DD:EE:FF,my-device-name- Restart the DNS service:
sudo service pihole-FTL restartNow my-device-name.home.lan resolves to that device on your network.
Verify it's working
On any machine on your network, run:
dig +short -x $(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)If everything's wired up properly, you'll see your custom hostname come back.
Is it worth it?
Absolutely. The difference is immediately noticeable: pages load faster, there's less visual noise, and you stop seeing the same targeted advert for something you already bought following you around the internet. One of those rare projects where the effort-to-reward ratio is absurdly good.
