RackedPrice
Project guide

Block ads on every device with Pi-hole or AdGuard Home

A Raspberry Pi that blocks ads and trackers for every phone, laptop and smart TV in the house, including the ones you can't install an ad blocker on.

Difficulty
Beginner
Time
About an hour

Drafted with AI assistance, fact-checked and approved by RackedPrice. Checked Nov 24, 2026.

Every time a device opens a website or an app loads an ad, it first asks a DNS server for the address of that name. Pi-hole and AdGuard Home are DNS servers that run on a small computer in your home and simply answer "no such place" for known ad and tracking names. Point your router at it, and every device on your network is covered, including smart TVs and apps where you can't install an ad blocker.

What you'll learn
  • What DNS is and how a DNS ad blocker works
  • Its limits, and why some ads still get through
  • How to set up a Raspberry Pi with no screen, over SSH
  • How to point your whole network at it, and how to undo it

What it does, and doesn't

  • It blocks ads and trackers in apps, games, smart TVs and websites, for every device on your Wi-Fi, with nothing to install on them.
  • It can't remove most YouTube ads. As Pi-hole's own forum puts it, in-video ads are typically served from the same domain as the video, so blocking them would block the video too.
  • A browser using its own secure DNS can go around it. Chrome's secure DNS is on by default in automatic mode, and if a custom secure DNS provider is picked there, Chrome uses that instead of your network's DNS. If ads still show in one browser, check that setting.
  • Now and then it blocks something you want, like a link in a marketing email. One click in its web page allows that name again.

Pi-hole or AdGuard Home?

Both are free and do the same core job well. Pi-hole is the classic, with a huge community and router guides for most brands. AdGuard Home is a single program with a friendly setup wizard. This guide uses Pi-hole and gives the AdGuard Home steps at the end. Pick one, not both.

Set up the Pi

  1. On your normal computer, install Raspberry Pi Imager. Pick your Pi model, then Raspberry Pi OS Lite (64-bit). Lite has no desktop, which a server doesn't need.
  2. In Imager's settings before writing, set a username and password and turn on SSH, so you can log in from your computer. Raspberry Pi's getting started guide shows each screen.
  3. Write the card, put it in the Pi, connect the network cable and power.
  4. Find the Pi in your router's app (it shows up as the name you gave it) and give it a reserved address ("DHCP reservation"). Pi-hole needs an address that doesn't change, and a DHCP reservation is just fine.
  5. From your computer's terminal, log in with ssh yourname@ plus the Pi's address, then update it: sudo apt update && sudo apt full-upgrade -y

Install Pi-hole

  1. Pi-hole's official one-step install is: curl -sSL https://install.pi-hole.net | bash
  2. Piping a script straight into bash runs whatever it says. If you'd rather read it first, the same page shows how to download the script and run it as a second step.
  3. The installer asks a few questions. The defaults are fine. When it asks for an upstream DNS provider, pick any from the list. That's where Pi-hole sends the lookups it doesn't block.
  4. At the end it shows the address of the web page and its password. Write the password down.
  5. Open the web page from any computer on your network: the Pi's address followed by /admin.

Point your network at it

  1. In your router's app, find the DHCP or LAN settings and set the DNS server to the Pi's address. Every device picks it up the next time it reconnects. Restarting your phone's Wi-Fi speeds that up.
  2. Leave the second DNS box empty, or put the Pi in it too. A public DNS as a backup sounds safe, but devices use either one at random, so ads leak through.
  3. Some internet-provider routers don't let you change DNS. Then turn on Pi-hole's own DHCP server in its settings and turn off the router's, so Pi-hole hands out addresses and itself as the DNS. AdGuard's docs suggest the same fix.
  4. Check it works: open a few sites on your phone, then look at Pi-hole's query log. You should see your phone's lookups, some of them blocked.

AdGuard Home instead

  1. Download the Linux ARM64 build from AdGuard Home's releases page onto the Pi and unpack it.
  2. Inside the AdGuardHome folder, install it as a service, as AdGuard's getting started guide shows: sudo ./AdGuardHome -s install
  3. Open the Pi's address on port 3000 in your browser (for example http://192.168.1.53:3000) and follow the setup wizard. Then point your router at the Pi exactly as above.

Keep it running

  • Update Pi-hole now and then with pihole -up, and the Pi itself with the same apt command as above.
  • If the Pi ever dies, the house loses the internet's address book. The quick fix is to set your router's DNS back to automatic. The careful fix is a second Pi-hole on another little box, set as the router's second DNS.
  • If a site or app breaks, check the query log for blocked names around that time and allow the one it needs.

Stuck?

  • Nothing is being blocked: a device may still have the old DNS. Turn its Wi-Fi off and on, and check the router's DNS setting saved.
  • The web page won't open: check you're using the Pi's reserved address, and that the Pi is plugged into the router with the cable.
  • Ads still show in one browser: check its secure DNS setting, as above.
Shopping list (optional)

Parts used in this guide

Already have the gear? You don't need anything here.

What you can skip: Already run a home server that's on all day? You can skip the Pi and run Pi-hole or AdGuard Home on that, though a separate little Pi keeps the internet working while you tinker with the server.

Raspberry Pi 5 2GB
Plenty for this job. Pi-hole asks for far less memory than this board has.
Raspberry Pi 27W USB-C power supply
The official supply. Cheap phone chargers cause random restarts.
Raspberry Pi 5 case
Keeps it tidy and cool next to the router.
A microSD card, 16GB or bigger
Holds the system. A name-brand card lasts longer.
A short network cable to your router
The whole house's lookups go through this box, so give it a cable, not Wi-Fi.
Planning a whole build? Pick every part from the gear we track and get a live total in the Better Wi-Fi & network planner.