Block ads at home using Pi-hole and a Raspberry Pi

Today’s blog post comes from Jacob Salmela, creator of Pi-hole, a network-wide ad blocker used by Raspberry Pi enthusiasts to block advertisements on all devices connected to their home network.

What is Pi hole?

An explainer video about the network-wide ad blocker and how to install it.

What is Pi-hole?

Pi-hole is a network-wide ad blocker. Instead of installing adblockers on every device and every browser, you can install Pi-hole once on your network, and it will protect all of your devices. Because it works differently than a browser-based ad-blocker, Pi-hole also block ads in non-traditional places, such as in games and on smart TVs.

I originally made Pi-hole as a replacement for the AdTrap device. I have a background in networking, so I figured I could make something better with some inexpensive hardware like the Raspberry Pi. I spent two summers working on the project and made the code open source. Four years later, we have several developers working on Pi-hole, and we have grown into a very large project with a vibrant community.

How does it work?

Pi-hole functions as an internal, private DNS server for your network. For many home users, this service is already running on your router, but your router doesn’t know where advertisements are — but Pi-hole does. Pi-hole will intercept any queries for known ad-serving domains and deny them access, so ads won’t be downloaded.

Using Pi-hole on a Raspberry Pi

Users configure their router’s DHCP options to force clients to use Pi-hole as their DNS server.

This means websites will load normally but without advertisements; since ads are never downloaded, sites will load faster. Pi-hole also caches these queries, so responsiveness to commonly visited websites can also be noticed.

Pi-hole and Raspberry Pi

The Pi-hole software has very low resource requirements and can even run on a Raspberry Pi Zero W. And despite its name, you can also install Pi-hole on several other Linux distributions. Many users install it on a VM or in a container and let it provide services that way. But since Pi-hole’s resource requirements are so low, many users have found it to be a good use of their older, lower-powered model Raspberry Pis. Simply install Pi-hole, connect the Pi to your router, and begin blocking ads everywhere.

Using Pi-hole on a Raspberry Pi

The Pi-hole web interface allows users to monitor ad-blocking data, to access the query log, and more.

You can also pair Pi-hole with a VPN to get ad blocking via a cellular connection. This will help you with bandwidth limits and data costs, because your phone won’t need to download advertising videos and images.

Install Pi-hole

Pi-hole can be downloaded to your Raspberry Pi via a one-step automated install — just open a terminal window and run the following command:

curl -sSL https://install.pi-hole.net | bash

You can find more information about setting up Pi-hole on your Raspberry Pi on the Pi-hole GitHub repository here.

If you need support with using Pi-hole or want to chat with the Pi-hole community, you can visit their forum here.

If you’d like to support Jacob and the Pi-hole team as they continue to develop the functions of their ad-blocker, you can sign up as a Patreon, donate directly, or purchase swag, including the Pi-hole case from Pi Supply.

14 comments

Avatar

I spent some time putting together this guide for those that want to do a headless install of Pi-hole on Raspbian Lite: https://www.myhelpfulguides.com/2018/07/15/install-pi-hole-raspbian-lite/

Avatar

A really excellent fightback against corporate and political manipulation.

Also it saves on bandwidth costs and reduces the impact of advertising (malware embedded in random adverts).

A really great use for an old RasPi which is inherently more secure than Intel/AMD based platforms.

Richard

Avatar

https://youtu.be/tUvxwe-hahw
I have made a video about how to install pihole and show setting up dns in different router go ahead and check it out.
Thanks.

Avatar

Found a use for an old Mac Mini laying about the office! Now running Ubuntu Server 18.04 and PiHole…

Avatar

This is how I put my old Pi B out to pasture. Plopped it right next to the router, even powering the Pi from the router’s USB port. I found that the wired connection makes Pi-Hole perform even better. Not just is Pi-Hole blocking adverts, it also shows me devices on my network that are excessively trying to call the interwebs (looking at you, webcam!) and allows me to block them as much as needed.

Avatar

What a clever concept, will definitely be looking at this in greater depth, someone could make a lot of money selling these, Advertisers beware.

Avatar

Hey Doc!

While we think our first-time setup is pretty simple, we’ve teamed up with Pi Supply to provide a pre-made working Pi-hole (along with a pretty case) for those that want an even simpler setup. It’s pretty easy to find a link to their page if that’s something that interests you, even if just to spread the word!

Avatar

That is good news, was not thinking of profit for myself but the benefits to other people, this is in effect mass cold calling by the big corporates, so will be spreading the word to as many people as possible via social media, Kind regards Doc Cox.

Avatar

Nice work mate, can we install this on a usb stick? like amazone fire or Pi Zero USB Stem

Avatar

Thanks so much

Avatar

Can you explain the benefit of whitelisting

Avatar

Hey Soy,

Sometimes a blocklist may contain a false positive (commonly: a site that got blocked which shouldn’t have been) and in this case, adding that blocked site to your whitelist means you’ll be able to access the site again.

Same goes for blacklisting – you can manually add a site to be blocked, if you don’t want it to be accessed from any device on your network.

Avatar

I tried Pi-hole but it’s overblocking too much. I’d spent a lot of time tuning the whitelist because some sites stopped working. Also it doesn’t respond with NXDOMAIN for blocked domains but with a localhost IP, which leads to sites loading forever.

Avatar

WaLLy3K doing gods work!

For those that are fans of Docker, Raspberry Pis and PiHole, I’ve combined all 3 in a guide here https://dxpetti.com/blog/2018/running-pi-hole-on-docker/

Leave a Comment

Comments are closed