← All posts

Weekend project: block ads on your whole network with a Raspberry Pi

Browser ad blockers protect one browser on one device. A Pi-hole protects everything on your Wi-Fi at once — the smart TV, the phones, the console, the fridge that inexplicably has a screen — by filtering ads and trackers at the network level. It runs on a $15 computer, involves no soldering, and a first-timer can finish it in an evening. Here's the whole build, start to finish, including the parts that most write-ups gloss over: what it genuinely won't block, and what to do on day two when a site breaks.

What a Pi-hole actually is

Every time any app on any device wants to load something from the internet, it first asks a phone-book question: "what's the address for ads.example.com?" That lookup system is DNS, and normally your router forwards those questions to your internet provider or a public resolver.

Pi-hole is free, open-source software that takes over that phone-book job for your whole network. It keeps a long list of known ad and tracker domains, and when a device asks for one of them, Pi-hole simply refuses to hand over the address. The request dies before a single byte of the ad is downloaded. Everything else passes through to a real DNS resolver as usual. This design is called a DNS sinkhole: ads aren't hidden after they load — they never load.

Because the filtering happens at the network layer, it covers devices you could never install an ad blocker on. Your smart TV's home-screen telemetry, the tracking calls inside mobile games, the analytics beacons in "free" apps — if the domain is on the list, it goes nowhere.

Despite the name, Pi-hole isn't picky about hardware. It officially supports Raspberry Pi OS, Debian, Ubuntu, Fedora and several other Linux distributions, and its demands are tiny: 512 MB of RAM and 2 GB of free disk space (4 GB recommended)[1]. A Raspberry Pi is simply the cheapest, quietest, most set-and-forget way to run it.

What it blocks — and what it honestly doesn't

This is where most Pi-hole articles oversell, so let's be precise. Pi-hole sees exactly one thing: domain names. For any given domain it has two options — answer the lookup or refuse it. There is no third option[2].

That works beautifully when ads come from dedicated ad domains, which is most of the display-ad and tracker ecosystem. It fails when a service serves ads from the same domains as its actual content. YouTube is the canonical example: the video stream and the ads come from the same infrastructure, so blocking the ad domains means blocking the videos. Pi-hole's own community FAQ is upfront that in-video YouTube ads are effectively out of reach, and recommends a browser-level blocker like uBlock Origin for that job[2]. The same logic applies to ads inside Facebook, Instagram and most big first-party platforms.

So set expectations accordingly. You'll notice: cleaner pages on many ad-heavy sites, quieter smart devices, fewer trackers following you between apps, and a dashboard that shows just how chatty your gadgets are. You won't notice: any change to YouTube ads, in-app ads served first-party, or sponsored results inside search engines. Pi-hole plus a browser extension is the honest combination, not a rivalry.

And yes — we see the irony of publishing this on a site that pays its hosting bill with ads; our view is that unobtrusive ads fund free tools, and what you block on your own network is entirely your call.

The parts list

Everything below is current as of July 2026, with prices from raspberrypi.com[3]:

No monitor, keyboard or soldering iron required — we'll do the whole setup "headless" from your existing computer.

The build, step by step

Step 1 — flash the operating system

Download Raspberry Pi Imager (free, for Windows, macOS and Linux) from raspberrypi.com[4]. Insert the microSD card into your computer, pick your Pi model, and choose Raspberry Pi OS Lite as the operating system — "Lite" means no desktop, which is exactly right for a box you'll never plug a monitor into.

Before writing, don't skip Imager's customisation screen — it's what makes the headless setup painless. There you can set a hostname (something memorable like pihole), create your username and password, enter your Wi-Fi network's credentials, and enable SSH so you can log in remotely from the first boot[5]. Fill in all four, write the card, then put it in the Pi and plug in power.

Step 2 — connect to the Pi

Give it a minute or two to boot, then from a terminal on your computer (Terminal on macOS, PowerShell on Windows) connect with the username and hostname you chose: ssh yourname@pihole.local. If .local names don't resolve on your network, find the Pi's IP address in your router's device list and use that instead. Once you're in, bring the system up to date with sudo apt update && sudo apt full-upgrade.

Step 3 — run the Pi-hole installer

Pi-hole's official install method is a one-liner[6]:

curl -sSL https://install.pi-hole.net | bash

Piping a script straight from the internet into your shell is a practice worth side-eyeing, and Pi-hole's own docs acknowledge the controversy — they offer alternatives where you download the script first, read it, and then run it[6]. (Our guide to verifying downloads covers the general habit.) Either way, a friendly text-mode wizard walks you through the choices: pick an upstream DNS provider (any of the listed ones is fine), accept the default blocklist, and keep the web admin interface enabled. The installer will remind you that Pi-hole needs a static IP address to do its job[1] — the cleanest fix is a "DHCP reservation" for the Pi in your router's settings, so it always gets the same address. When the installer finishes it prints the address of your admin dashboard and a password for it; write both down.

Step 4 — point your router at it

Right now, Pi-hole is a bouncer standing at a door nobody uses. The fix is one setting: in your router's admin page, find the DHCP or LAN settings and set the DNS server to your Pi-hole's IP address. That's the method Pi-hole's docs recommend, because every device on the network picks it up automatically. If your router doesn't let you change its DNS setting (some ISP-issued boxes don't), Pi-hole can act as your DHCP server instead — disable the router's DHCP first — or, as a last resort, you can point each device at the Pi-hole manually[7].

Devices adopt the new DNS when they renew their lease, so toggle Wi-Fi off and on to hurry things along. Then open the admin dashboard, load a few websites on your phone, and watch the query log light up. That moment — seeing every lookup your gadgets make, and the blocked ones dying in real time — is the whole payoff of the project.

Day two: breakage, upkeep and household diplomacy

Sooner or later something will misbehave — a tracking-wrapped link in a marketing email won't open, a coupon site won't load, an app's login flow stalls. This is normal, and the fix takes seconds: check the dashboard's query log for the red blocked entry, then whitelist it from the web interface or over SSH with pihole allow thedomain.com[8]. Expect a small flurry of these in week one, then near silence.

Maintenance is genuinely light. The blocklists are compiled into a database Pi-hole calls gravity, which updates itself automatically every week; pihole -g runs the update on demand, and pihole -up upgrades Pi-hole itself when a new release lands[8]. That's the entire routine.

One social tip: tell your household what changed and how to reach you when a page acts up. The dashboard has a temporary "disable blocking" button for genuine emergencies — better that they ask you than that they blame the internet.

The honest alternatives

Pi-hole isn't the only way to get this. AdGuard Home is the closest rival — the same DNS-sinkhole idea, open source, shipped as a single program with a polished interface and encrypted-DNS support built in; it runs happily on the identical hardware, and choosing between the two is mostly taste. Hosted filtering services do the same filtering in the cloud with no hardware at all, in exchange for routing your DNS history through a third party. And if the only ads you actually care about are the ones in your own browser, a good extension like uBlock Origin blocks more (including YouTube), costs nothing, and takes thirty seconds to install — no Pi required. The case for Pi-hole is specific: you want the whole network covered, including every screen and gadget you can't install an extension on, and you'd rather the filtering happen on a box you own.

Sources

  1. Pi-hole documentation — Prerequisites, accessed July 2026
  2. Pi-hole Userspace (official forum) — How do I block ads on YouTube?, accessed July 2026
  3. Raspberry Pi — Products, accessed July 2026
  4. Raspberry Pi — Raspberry Pi Imager, accessed July 2026
  5. Raspberry Pi — Getting started documentation (Imager OS customisation), accessed July 2026
  6. Pi-hole documentation — Installation, accessed July 2026
  7. Pi-hole documentation — Post-Install, accessed July 2026
  8. Pi-hole documentation — The pihole command, accessed July 2026

Related: How to verify a download with checksums · Why Toolkit runs entirely in your browser · All posts