How to block ads everywhere

Building a black hole for online ads with a Raspberry Pi

Tutorial Raspberry Pi
By Ferdinand Vogler 15.05.2020 7 min read

Ads suck

Browsing the internet feels like visiting a Las Vegas Casino. Advertisements popping up everywhere are a tightrope act for your attention. You know these browser extensions that block ads? They work with varying success. What about your smartphone, tablet and your TV? Or family members that aren’t as tech-savvy and don’t have these blockers installed? Shouldn’t they also profit from a better browsing experience? At best you pay quality content creators, but lets be honest: most ads suck, use up valuable bandwidth and ignore privacy laws. It doesn’t have to be that way.

Raspberry Pi

Meet the device that eats ads for breakfast

Pi Hole solves all that. Its a software, that you install on a tiny computer called Raspberry Pi. This is connected to your Wifi router and blocks ads before they even get sent to the devices in your network. Sounds too technical? I thought the same, but setting it up is easy. I didn’t find an instruction for beginners like me, so I wrote one.

What you need



Download the following software and have it ready.


Step 1

Plug in your MicroSD card and make sure it shows up as an external drive. Open the balenaEtcher application and select the ZIP-file for Raspbian Buster Lite. The target is your MicroSD card. Click “Flash”.

Step 2

Open the MicroSD card from Finder and create an empty file called ssh in the root. This tells your operating system Raspbian that you want to able to access your Raspberry Pi via SSH (command line) → Download this file here

Step 3

Eject the MicroSD card from Finder. Put it into your Raspberry Pi’s MicroSD slot. Plug the Raspberry Pi into a power source. Connect it with your cable to a free Ethernet slot on your Wifi router. Since your Raspberry Pi is now connected to your home network, you can “talk” to it and give it instructions via SSH.

Step 4

Start the macOS app “Terminal”. We will now access the Raspberry Pi via SSH to install Pi Hole on it. Type the following and hit ENTER.

ssh pi@raspberrypi

Enter the default password raspberry. We will change this later.

Step 5

If everything went well you now logged on to your Raspberry Pi. Change the password by typing passwd and hit ENTER. Type your old password and define a new one. Its normal that the characters don’t show up, just pay attention and save your new password somewhere safe.

Step 6

Let’s make sure you have all the latest software. Type the following and hit ENTER after each line.

sudo apt-get update
sudo apt-get dist-upgrade

Step 7

Download the installation script for Pi Hole by typing the following two commands. Hit ENTER after each line.

wget -O
sudo bash

A setup wizard will start that guides you through the installation. Read each screen but you can basically just swift through it by pressing ENTER on each screen.

Step 8

After successful installation you will be shown the IP address of your Pi Hole. Enter this IP address as a DNS server in your Wifi router’s settings. For FritzBox routers you access the admin interface by typing in your browser’s URL bar. How to enter the admin interface of your router depends on what model it is. Search it on the internet, you’ll find instructions for that.

All internet traffic will be redirected through this IP address (and by that through your Raspberry Pi running Pi Hole). Pi Hole then tells what internet traffic to let through. If its an advertisement, it gets blocked and it never shows up on your device.

You can access a nice interface in your browser by suffixing your Pi Hole’s IP address with /admin e.g. Here you see how much ads where blocked and you can make further adjustments. If for your work you rely on services like the Google Tag Manager to work, you can allow these URLs again (whitelisting). Its also possible to define device categories that allow these URLs. So your MacBook would still the Google Tag Manager go through, but your mobile devices and your TV won’t.

Remove password in the admin interface

If you don’t want to enter a password each time you go to your Pi Hole admin interface, you can deactivate the password. Beware that this means everybody in your network can access the admin tools and make changes. Connect to your Raspberry Pi via SSH and type:

pihole -a -p

Is your life better now?

If you love your new ad-free internet life, donate to the project. It’s completely open source and the developers spend their own money to make this possible. A cause worth giving back to.

Comment this article