How to Block Ads with Pi-Hole

Have you ever been browsing the internet and come across a really intrusive advertisement? Well, there’s something you can do about that. Enter the Raspberry Pi. Unfortunately I’m not talking about a tasty pie you can eat. Raspberry Pi’s are the most common single board computers. This means everything they need to operate is on one printed circuit board (PCB). The best part about them is they don’t need active cooling and they are low power. Their cost also makes them accessible being less than $100 to get up and running. We are going to use one to block ads with a Pi-Hole.



Raspberry Pi’s

If you stopped reading this article and looked at purchasing a Raspberry Pi, you might have noticed they are only $35 dollars. The reason I say around $100 to get up and running is $35 is just for the board. You still need a MicroSD card and a power supply at a minimum. I also recommend a case just to prevent accidental damage to the board.


The Project

All of this was leading up to a Raspberry Pi project. There’s a software project called Pi-Hole which les you setup and manage your own Domain Name System server (DNS). If you’re not familiar with DNS it resolves domain names, such as to point to a computer’s IP address. Computers don’t understand names so the DNS server translates the name into something they understand. While the Pi-Hole was designed to run on Raspberry Pi’s it can be run on any computer. If you’re deploying this solution in your home, the Pi should have no problems keeping up with the DNS requests.



Pi-Hole also supports being used as a dynamic host configuration protocol (DHCP) server. This is the preferred way to use Pi-Hole. DHCP allows clients or computers to receive an internet protocol (IP) address. They can also be configured to give more information such as a DNS server. Since Pi-Hole is going to be our new DNS server, this is quite handy. If we didn’t use DHCP, then we’d need to manually input the DNS server address on every computer on our network. Depending on how big your network is, that could be a daunting task. With Pi-Hole being used as a DHCP server, we need to make sure another device on the network is also not trying to give out addresses. Typically this is the job of your router. You will need to login to your router and disable the DHCP server. The steps to do this are different for every router so looking up your device’s documentation is recommended.



If you don’t want to run a DHCP server on the Pi-Hole, you can configure the DHCP server on your router to assign clients Pi-Hole’s DNS server IP. Phew, that was mouth full. The reason Pi-Hole supports running a DHCP server is because not all routers support adding custom DNS servers. This is primarily an issue on routers provided by internet service providers (ISP). If you’re not sure how to add custom DNS servers in your router, consult the documentation from the manufacture’s website.


We Interface

Pi-Hole has a lovely web interface to configure to your new DNS server. It features a dashboard with queries, blocked queries , and how many domains are on the blocklist. The bread and butter of this is the ability to add your own block lists. By default Pi-Hole has a good selection of block lists but you can research and add your own or even add your own domains to block. Want to prevent your kids from accessing a website, no problem, simply add it to the block list. It also has the ability to whitelist a site which is on a block list. Lets say you are using a blocklist for social media websites which includes but you want your kids to have access to it because it has great learning resources on it. You can simply add YouTube to the whitelist to allow it through.


How it Works

You might be thinking Pi-Hole sounds great and all but how does it work? Whenever you are trying to access a website, your device or computer asks Pi-Hole what the IP address of that site is. Since the site is on a block list, Pi-Hole just tells your device it’s and your devices cannot connect to that IP address. It effectively gives the device false information. That said, the end result is the same. If you are having issues accessing a website you normally have access to, Pi-Hole might be blocking it. One of the block lists could have added a site you regularly use. There’s an option in the web interface to temporally disable Pi-Hole to see if it was being blocked or not.


If this project sounds interesting, I recommend giving it a try. You can learn a lot about Linux, DHCP, and DNS servers.

Leave a Reply

Scroll to Top