Pi-hole for the whole house, and the rate limit that took my laptop offline

By Ali Raza ·

Pi-hole is a DNS server that blocks ads and trackers before they load. Most guides set it up for one computer. I wanted it for the whole flat: both phones, the TV, the smart speaker, guests on the Wi-Fi. This is how I did it on an old laptop that already runs my other home services, and the three things that bit me.

What you need

  • Any always-on Linux box. Mine is a 2018 laptop with 16 GB of RAM, plugged into the router by Ethernet. Pi-hole itself needs almost nothing.
  • Docker with the Compose plugin.
  • Access to your router’s settings, either the web page or the app.
  • A fixed address for the Pi-hole box on your home network. In the router, that’s called a DHCP reservation.

Step 1: give the box a fixed address

If the box’s address changes, every device in the house loses DNS. Open your router’s DHCP settings, find the box by its wired MAC address, and reserve its current address. Do it for the wired port, not the Wi-Fi card. A laptop that falls back to Wi-Fi gets a different address and you’re back to square one.

Step 2: run Pi-hole in Docker

My compose.yaml looks like this, with the LAN address swapped for a placeholder:

services:
  pihole:
    image: pihole/pihole:latest
    container_name: pihole
    ports:
      - "192.168.1.50:53:53/tcp"
      - "192.168.1.50:53:53/udp"
      - "127.0.0.1:8081:80/tcp"   # admin page, only on this machine
    environment:
      TZ: "Europe/London"
    volumes:
      - ./etc-pihole:/etc/pihole
    restart: unless-stopped

Bind port 53 to the box’s LAN address, not to 0.0.0.0. Docker writes its own firewall rules and skips UFW, so a bare port is open to more than you think. I keep the admin page off the LAN entirely and reach it over my VPN.

If your firewall is on, allow DNS from your home network only:

sudo ufw allow from 192.168.1.0/24 to any port 53

Step 3: point the router at it

In the router’s DNS settings, set the primary DNS server to the Pi-hole box. My router also asks for a secondary. I put 1.1.1.1 there so the internet still works if the laptop is off.

That fallback has a cost. Some routers don’t treat the secondary as a backup, they spread queries across both. So a few ads leak through. I accepted that, because the alternative is no internet for the whole house every time I reboot one machine.

Trap 1: the rate limit that cut off my own laptop

Pi-hole limits how many queries one client can send per minute. The default is 1,000 a minute. One evening I ran a script that checked a few hundred streaming URLs, and each check did several DNS lookups. Pi-hole decided my laptop was abusive and started answering REFUSED.

What made it nasty: refused lookups get retried, so the burst feeds itself. My laptop couldn’t resolve anything, while dig @1.1.1.1 example.com worked fine. It looked like a broken network.

How to spot it:

docker logs pihole | grep -i rate-limiting

I raised the limit to 5,000 a minute:

docker exec pihole pihole-FTL --config dns.rateLimit.count 5000

The bigger lesson is to cache and throttle in any script that does lots of lookups.

Trap 2: every device shows up as the router

Once the router forwards DNS to Pi-hole, the query log shows one client: the router. Clients still get the router as their DNS server from DHCP, and the router passes everything on. Devices on my VPN all show up as the Docker bridge address too.

So you can’t block one device and not another. If that matters to you, change the router’s DHCP to hand out the Pi-hole address directly, and run Pi-hole on host networking.

Trap 3: the machine that hosts DNS shouldn’t depend on it

At first my laptop used Pi-hole too. Then a reboot started Docker before the network was fully up, Pi-hole failed to start, and the laptop had no DNS. So I couldn’t easily fix the thing that was broken.

Now the Pi-hole box resolves through Cloudflare directly and is exempt from its own blocklist. If Pi-hole dies, the box hosting it still has internet, and I can fix it from anywhere.

A bonus: a bedtime curfew

Because the whole house goes through Pi-hole, it’s also a switch. I run a small script every two minutes that adds regex blocks for Instagram, TikTok, X, Facebook and Snapchat between 23:00 and 09:00, and removes them in the morning. One tip if you try it: check the query log for lookups that got through during the window. TikTok’s UK and EU servers use different domain names from the ones in most lists, and videos kept playing until I matched them by prefix.

It won’t stop anyone determined. Switching to mobile data, a VPN or the browser’s secure DNS all get round it. I only wanted something that makes scrolling at midnight a bit more annoying, and it does that.

Was it worth it?

For me, yes. The TV’s calls to Samsung’s ad and tracking servers now go nowhere, and the same goes for every phone and laptop in the house. It cost nothing but an evening. If you try it, set the fixed address first, keep a fallback DNS in the router, and don’t let the Pi-hole box rely on itself.

If you like small tools that just work, I make free browser games and apps at cloudmaking.co.uk.

Spotted a mistake or have an idea? Send feedback.

More posts