Setup your own DNS sinkhole

Setup your own DNS sinkhole

Are you tired of seeing advertisements on the internet? What about on your TV or your phone? In this post I'll show you how to setup a DNS sinkhole using Pi-hole on your own home network as an IoT device managed with Balena.

What really happens on your network?

In addition to blocking advertisements your Pi-Hole also doubles as a network monitoring tool. Have you ever wondered if your TV is spying on you? What about your Dish Washer? What about all those Wifi enabled outlets that let you turn on the lights without getting up from the couch?

Here are some other things your Pi-Hole can do:

If  you want to see more examples I recommend reading through this thread.

Getting started

You'll need a few things in order to get started:

  • A raspberry PI (Preferably a Raspberry Pi 4 Model B)
  • An SD card (Preferably with at least 16Gb of storage)
  • An ethernet cable

Setting up your Raspberry Pi with BalenaCloud

Once you've got your hardware you can signup for an account with Balena here. Don't worry about pulling out your credit-card as your first 10 devices are always free and full-featured!

balena - The complete IoT fleet management platform
Infrastructure and tools to develop, deploy, and manage connected devices at scale. Your first ten devices are always free.

From there you can follow these instructions on how to create a new application.

I went with the name pihole for mine, we'll use that later on in the guide.

When you're finished you'll be provided an OS image you can flash onto your SD card. Just pop in the SD card into your Raspberry Pi, plug it in and connect it to your router with the ethernet cable.

In just a few minutes you should see your device become available on your Balena dashboard. Great! From here on out you should never have to touch your device (given there's an internet connection). You can reboot it, make it blink, find its GPS coordinates, etc all from the Balena interface.

Deploying Pi-Hole to your Raspberry Pi

Now that you've got a managed IoT device you're ready to install Pi-Hole!

Luckily there's a project that already does the heavy-lifting for us here.

Pi-hole is a Linux network-level advertisement and Internet tracker blocking application. - klutchell/balena-pihole

All we need to do is clone this project locally and push it to Balena using their CLI.

First get setup with the Balena CLI here.

Once you've authenticated via balena login you can deploy your project like this:

git clone
cd balena-pihole
balena push pihole

That's it! Once Balena pushes the project to your Raspberry Pi and the docker containers spawn you should be able to view your Pi-Hole dashboard at the "Local IP Address" listed in Balena dashboard.

Configuring devices to use the Pi-Hole for DNS

This part will depend on your hardware. If you aren't sure about how to configure DNS records on your device you can use this guide here.

Automatic upgrades

Your Pi-Hole automatically updates itself with the latest domain blacklist maintained by the community, but what about upgrades to the software itself?

You could pull the latest changes from klutchell/balena-pihole down locally then perform another balena push from time to time but this would be silly.

Instead, I glued this project together with Dependabot and GitHub Actions so that my only responsibility is to merge Pull Requests that are automatically opened each time there's an update to the klutchell/balena-pihole project. This keeps my Pi-Hole up-to-date with minimum effort.

Checkout the glue here.

A network-level black hole for internet advertisements running on a Raspberry Pi deployed via BalenaCloud. - cburmeister/pi-hole
Show Comments