Use Pi-Hole to Block Ads with Raspberry Pi

We live surrounded by ads. Not only in the physical space, but also in the virtual reality of Internet. They don’t just consume a lot of bandwidth and are very obstructive, they usually also unethically track you. While I understand, that content creators need the means to make ends meet, I believe there are better ways to accomplish that, such as Patreon. Now, there are plenty of ways to get rid of ads on traditional computers. For example, browser extensions, such as Privacy Badger and uBlock Origin, or proxys, such as Privoxy). However, on mobile devices, the situation is far less ideal. One way to tackle the problem, is to filter out ads for your whole network. Welcome to Pi-Hole. It is a DNS server for Raspberry Pi, that keeps a blacklist of advertising sites and serves an empty response instead of them, saving both your bandwidth and your sanity.


As you can see on its website, Pi-Hole’s installation process is very easy. Once you have your Raspberry Pi set up, connect to it via SSH. Then run the following command to download Pi-Hole:

$ curl -L | bash

Next, open the necessary ports if you are using ufw:

$ sudo ufw allow dns
$ sudo ufw allow http

Take a note of your Pi’s IP address:

$ ip addr

Lastly, open the settings of your router and change the DNS address to the address of your Pi.


You are done. No more ads on any of the devices connected to your network. And if you want to see how many ads has Pi-Hole blocked, just type your pi.hole/admin into your browser and smile (and optionally whitelist websites, that are sensible about the ads they show).

Pi-Hole Dashboard