How To Block Ads On Your Network Using Pi-Hole And A Raspberry Pi

Blocking ads on your local network is really straightforward with a raspberry pi all you need to do is install some software called Pi-Hole on it and then make sure you use the Raspberry Pi as your DNS server instead of Google ( or Cloudflare ( directly. You can still use those, but they will be the upstream of your Pi-hole instance instead. Later on you can dive into this article where I actually integrate a DNS Proxy service called SmartDNS into Pi-Hole which enables me to block ads and get BBC iPlayer outside of the United Kingdom and the full US Netflix catalog.

What you will need: (a router, computer and internet goes without saying…)

  • A Lan cable to connect the Raspberry Pi to your router on your home network.
  • A USB memory card reader to load the OS onto the SD card.
  • A Raspberry PI computer and a memory / SD card (I recommend a SD card with 16GB minimum, but you can get away with 8GB), you will need the Pi 3 Model B or Model B+ you do not need a Pi 4, but if you want one it will work better as it is a lot more powerfull, but the Pi 3 is more than sufficient for what we are going to use it for.

You can buy a Raspberry Pi from these places depending on where you live:

If you live in the United States or in the United Kingdom:

Raspberry Pi Kit (includes a case, a memory card, power adaptor and the PI itself) from Amazon this is the one I used in the tutorial, very neat set up.

If you live in South Africa:

Raspberry Pi Kit from PiShopNetram or DIY Electronics. I have used all of them before.

Note: Shop around on classified sites as well for a second hand raspberry pi, you will see people buy this computer thinking it will change their lives and then not realize its just a normal small form factor PC, it cannot do anything without you programming it to do something and then people end up selling it at half price. In other words, check gumtree, check craig’s list and Ebay, there are bound to be a lot of specials on second hand Raspberry Pi computers.

Step 1: Install an operating system on your Raspberry Pi

We will be installing the Raspberry Pi OS (previously called Raspbian) as this is the primary operating system which the Pi Hole Devs test their system against followed by Ubuntu and Debian.

On a high level, this is what we will do: We are going to download the operating system and we are going to download a program that can write that OS to the physical memory card using your USB memory card reader. Once that is done you will put the memory card into the Raspberry PI and connect to it via a LAN cable from your PC (this is a headless installation – meaning you won’t plug a keyboard or monitor into the raspberry at all.) and then run the setup scripts to install Pi Hole which we will then control via the browser.

Let us get started

We are specifically going to use “Raspberry Pi OS (32-bit) Lite”, which you can download from here. After you downloaded this, please download the software required to write it to the SD card, called Raspberry Pi Imager from here.

Connect an SD card reader with the SD card inside.

Open Raspberry Pi Imager and choose the required OS (Raspberry Pi OS lite, 32 Bit) from the list presented.

Install the raspberry pi imager program to install raspberry pi os

Choose the SD card you inserted into your computer via the USB card reader in order to write the image to it.

Review your selections and click ‘WRITE’ to begin writing the data to the SD card.

Note: if you are using the Raspberry Pi Imager on Windows 10 with “Controlled Folder Access” enabled, you will need to explicitly allow the Raspberry Pi Imager permission to write the SD card. If this is not done, Raspberry Pi Imager will fail with a “failed to write” error.

Now you need to create a file called “ssh” without and extension and place it inside the boot partition. If you go to “This PC” on your windows machine and look at the SD card you will have two partitions. The first one, which is the smaller one, is the boot partition. Place the file into this one.

We do this because when the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.

You can now insert the SD card into the Raspberry Pi and power it up.

how to insert an sd card into a raspberry pi
Step 2: Connect the Raspberry Pi to your Router

Plug the lan cable into your raspberry and plug the other part into your router.

Step 3: Find the IP Address of the Raspberry PI

In a web browser navigate to your router’s IP address e.g., which is usually printed on a label on your router; this will take you to a control panel. Then log in using your credentials, which is usually also printed on the router or sent to you in the accompanying paperwork. Browse to the list of connected devices or similar (all routers are different), and you should see some devices you recognise. Some devices are detected as PCs, tablets, phones, printers, etc. so you should recognise some and rule them out to figure out which is your Raspberry Pi. Also note the connection type; if your Pi is connected with a wire there should be fewer devices to choose from.

If you struggle with this step, follow me on Twitter (@ErikThiart) and send me a tweet with a picture of your router then I will explain how to do it for your particular router.

Alternatively, you can get the IP address of a Pi using your smartphone by downloading the Fing App. Your phone and your Raspberry Pi have to be on the same network, so connect your phone to the correct wireless network.

When you open the Fing app, touch the refresh button in the upper right-hand corner of the screen. After a few seconds you will get a list with all the devices connected to your network. Scroll down to the entry with the manufacturer “Raspberry Pi”. You will see the IP address in the bottom left-hand corner, and the MAC address in the bottom right-hand corner of the entry.

Step 4: SSH into your Raspberry Pi using Putty (on windows).

Download & Install Putty. It is not really an Install as you can run the putty.exe directly.

Open Putty

how to enter an ip address into putty in order to use ssh

Enter the Raspberry Pi IP address, select SSH as connection type and under the menu item “Window” –> “Translation” select UTF-8

Click “Open” and you’re ready to log on.

Next you will be prompted for the password for the user as which you are trying to connect: the default password for the pi user on Raspberry Pi OS is raspberry. For security reasons it is highly recommended to change the default password on the Raspberry Pi.

You will see the following:

pi@raspberrypi ~ $
Configuring putty to use UTF-8 during ssh to the raspberry pi

You are now connected to the Raspberry Pi remotely, and can execute commands.

Step 5: Install Pi-hole on the Raspberry Pi

This bit is the easy part. Their intelligent, automated installer asks you a few questions and then sets everything up for you automagically.

Type in the following command into the putty terminal after you logged into the raspberry pi and press enter:

curl -sSL | bash
Install Pi-Hole on a raspberry pi using ssh

Follow the steps that will come up on the screen, they are mostly very easy to understand, send me a tweet if you get stuck.

Step 6: Use Pi-hole as your DNS server

Configure your router’s DHCP options to force clients to use Pi-hole as their DNS server, or manually configure each device to use the Pi-hole as their DNS server.

Log into your router’s configuration page and find the DHCP/DNS settings. Note: make sure you adjust this setting under your LAN settings and not the WAN.

Update the DNS setting on a router for Pi Hole

Important: If you have existing network devices on your network when you make this change, you will not see ads getting blocked until the DHCP lease is renewed. You can usually force a renewal by restarting the device.

Again, if you need help during this step, tweet a picture of your router to me on @ErikThiart and I will guide you through the process for your particular router.

Step 7: Get to know Pi Hole & accessing the Ad Blocker GUI via the browser.

You can access it by typing the IP address of your Raspberry Pi into your browser. In addition to blocking advertisements, Pi-hole has an informative Web interface that shows stats on all the domains being queried on your network. They also include an API for extending these stats.

Access the Pi Hole GUI through a browser

Queries are stored in a database and can be queried at any time. It allows you to learn about what’s happening on your network over time for example if you have an Amazon Alexa or Google Home Mini you can check if they are listening to you by eavesdropping into your private conversations.

Bonus: Additional Documentation for Pi-Hole

You can visit the official Pi Hole website if you get stuck along the way, or you can send me a tweet via Twitter (If you follow me then I respond near instantly).

If you found this guide to be useful and would like to make a donation, please head over to my donations page, I appreciate all the support I have received over the years from various readers around the world.

Popular Categories

Ad Blockers AWS Bitcoin CMD cPanel crypto Dark web Google IoT MikroTik Python Reviews SmartDNS Sonoff Tor VPN Windows WordPress Xiaomi Youtube Raspberry Pi

Subscribe (It's Free)

Featured Articles

Xiaomi Mijia 1080P 170 Degree Smart IP Camera with AI Human Detection
Xiaomi Mijia 1080P 170 Degree Smart IP Camera with AI Human Detection

I know this review is long, but I wanted to include all the details to help you decide. This smart security camera from Xiaomi had so much going for it, I still believe there a route for Xiaomi to redeem themselves and make this camera available to its full potential by issuing a firmware update to remove the restrictions and allow RTSP access from the Xiaomi camera.

Read The Article
How to choose the right web hosting company for your business
How to choose the right web hosting company for your business

There are plenty of web hosting providers out there, and it may seem difficult to decipher the good from the bad. So I have put together a guide on how to find the right web hosting provider for your business and my personal recommendation of who to use depending on where you are in the world. Teaming up with the right web hosting service is more important than you think. It’s a partnership. Opt for the wrong one and you could find yourself struggling to get support, suffering downtime, or worse.

Read The Article
The most important plugin for your WordPress website
The most important plugin for your WordPress website

Google’s official WordPress plugin. Get insights about how people find and use your site, how to improve, and monetize your content, directly in your WordPress dashboard. If you have a WordPress website and would like to see how users find and use your website, Site Kit is right for you. To help you build, maintain, and grow your online presence, Site Kit gives you easy-to-understand metrics and actionable insights directly on your WordPress dashboard.

Read The Article

Some articles you might also be interested in...

Kodak OG3.24 Inverter Review
Kodak OG3.24 Inverter Review

The Kodak OG3.24, a lot of potential, but a tainted experience.

Read The Article
A Beginner’s guide on how to browse the dark web with TOR
A Beginner’s guide on how to browse the dark web with TOR

First thing to understand is that on the hidden web, you do not know about a website unless that website is shared with you. The dark web’s content on the internet isn’t accessible through traditional browsers or standard browsing technology. Content on the dark web is designed to be hidden from search engines and from casual users – you can’t simply stumble across dark web websites by accident.

Read The Article
Review: Sonoff GK-200MP2-B a Wi-Fi and Lan enabled Wireless IP Security Camera
Review: Sonoff GK-200MP2-B a Wi-Fi and Lan enabled Wireless IP Security Camera

You probably know the Sonoff brand for smart home electronics like the POW R2 or the Sonoff Basic switches, but they also released a security camera, the Sonoff GK-200MP2-B. I decided to try it out and made an in-depth review so you can make the right decision. Considering this is Sonoff, a well-known brand for robust electronics. I expect a good working, premium product that just works especially since to use the Sonoff GK200MP2-B, you need the eWeLink application which integrates very well with other Sonoff devices.

Read The Article