TECH BITES

February 1, 2022

Network Wide Ad-Blocking using Raspberry Pi Pi-hole server

What is Pi-Hole

Pi-hole is a local DNS server that sits on your Raspberry Pi. Though you can set up a Pi-hole server in multiple ways like docker, virtual machine, but having it on a Raspberry Pi is more practical, convenient and cost efficient way.

How Does Pi-Hole Blocks Ads

Pi-hole maintains a local database of Ad domains. It functions by filtering out those Ad domains when you try to load a website. That is, it allows everything to load normally except the requests made by recognized Ad-lists.

How Good Is It?

I have been using Pi-hole since a long time. Frankly speaking, it works very well on websites and almost everything on desktop machines. But, it may or may not work with mobile applications like prime videos, YouTube, etc. Those applications have different ways of bypassing any adblocking software, and they keep on evolving them. So, it is a hit or miss.

What is the best network model for pi-hole?

There are two models which you can follow. Both of them are functionally good, but model 2 appears to be more convenient. Model 2 is the one I have implement at my home network.

  1. Setting Pi-hole along side your main router.

    This is certainly a great way to get started. You'll be able to see how it works and adapt your network according to your needs.  
    If your home router ip is 10.0.0.1 and your Pi-holes (raspberry pi's) static ip is 10.0.0.10, then
    you can either set the DNS from each device like iphone, ipad, mac to 10.0.0.10.
    Alternatively,
    You can set the DNS to 10.0.0.10 in your main router - 10.0.0.1
    Of course for trying out things, this method is fine. But, you would want to move to model 2. Because you don't want to block ads always. Some ads are evil necessity.
  2. Setting a 2nd router hooked to Pi-Hole

    This is certainly a more practical approach. Having 2 WIFI-networks provides you with the liberty to quickly switch between Ad-free and normal zone.  This also saves you from the hassle of changing the DNS configuration in your router of your mobile devices when ever you want to stop Ad-blocking. Pi-hole isn't perfect and there is no point in trying to adapt it by adding things in white list. Its way too time consuming and inefficient process.

Now, that we have covered the basics, lets dig into the processing to setting it up. Just a head's up - its easier than you think!

Setting up Pi-hole

I am using Raspberry Pi 3/4. But, you may use any version that you like. You can follow the along the installation process with me. But, all you need to so is copy-paste commands in the terminal and go through the instructions.

But before that,


If you want to follow along, you may have a look at the YouTube video I have made a while ago.

1. Find the ip address of your Raspberry Pi

Finding Raspberry Pi IP Address

An easy way to find the ip address is to log into your router and it will show up there. Once you have the ip address you can connect to the raspberry pi via VNC or SSH. I am more of a GUI person so, I prefer to use VNC.

Though I have configured my system to use IPv6, yours will most likely show IPv4 for the first time. You'll you that ip for SSH or VNC. That will also be the Ip address for your Pi-hole web page (admin page).

For first time users, it better to turn off ipv6 to avoid conflicts.

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

2. What should be my Raspberry Pi's IP address

Ideally, anything reasonably close to your main router's ip address is fine. Say 10.0.0.2/3/4 or 10. Be careful about setting the ip address in the same subnet.

3. RASPBERRY PI'S IP ADDRESS = PI-HOLE IP ADDRESS

This is where I screwed up couple of times while I starting out with this setup. Though, there are numerous way in which you can configure your pi-hole but this is the most straight forward one.
After all, the sole purpose of this guide is to get things working with minimum hassle.

All you need to do in initial few steps is keep on pressing the "ENTER" key. Pi-hole is smart enough to figure out what your network configuration is and where it could sit comfortably.

4. Please Note Down the Password

After you are done installing the pi-hole, it provides you with the password for logging into the admin page. Please, Please note that down somewhere carefully. I had a tough time retreivng that password and that was an additional unnecessary work that no one wants to get into.

5. Change the Router DNS to your Pi-hole

Setting Custom DNS

Once you are set with your Raspberry Pi, it's time to head onto your routers for configuring them to use your Pi-hole for resolving all the dns queries from your devices.

In your router page you might want to look for a field to set "custom DNS".
And if you you happen to use OpenWRT, it's right under

  • Interfaces
  • LAN/WAN/etc
  • Edit
  • Advanced Settings

If you Pi-hole doesn't seem to work during testing phase, you might what to turn off IPv6 or delegate IPv6 requests to  Pi-hole in similar way.

6. Logging Into The Pi-hole Admin Page

Pi-hole admin page

For logging into the Pi-hole admin page, you need to hit the following address from your web browser

For me it is 192.168.137.10 as you can see in the screenshot.

All you need to do is login to the page.

{ip address of raspberry pi}/admin

8. Testing if things are working

The best way to test whether pi-hole is working or not, is to head on to google with any random search, say "vacuum cleaner" or, head on to amazon.
By now you should be able to see changes in the green bar and blue bar of your admin panel (total queries and queries blocked).
If you still can't see changes, then something isn't working right. It has happened with me couple of times.
At this point you might want turn everything off and on again.
Give it another shot. If it's still not working, i have got you covered.

9. Solution for Pi-hole Not Working

Turning on Pi-Hole's inbuilt DHCP

Head onto you Pi-hole admin panel.

  • Settings
  • DHCP
  • DHCP server enabled
  • Turn off DHCP server in your WIFI/LAN router

So, you need to enable the DHCP server in your Pi-hole so that all your devices get register with Pi-hole itself.

This would solve most of such common issues.

  • Turn the system off and on again
  • Test again
  • If it's still not working then you might want to turn off IPv6 everywhere. IPv6 is the second most common culprit for this. It could entirely bypass your Pi-hole if not set properly and reach your main router.

Not Satisfied ? Want to Block More Ads?

Pi-hole works just fine out of the box. Pi-hole comes with a default Ad-list of about 100k. But, it doesn't block all the ADS. If you want to take your game to the next level, you can update your Ad-list to your liking. All you need to do is copy and paste a few lines from

https://firebog.net/

I personally prefer to add everything that ISN'T crossed out in Advertising Lists, Tracking&Telemetry Lists and Malicious lists. I have tried and this works very well for me. I tend to Suspicious Lists as it might not be that perfect.
Adding these additional domains will take your blocking list beyond 300k easily.
That being said, too much blocking isn't good. A massive blocklist could be more prone to false positives, which might obstruct you from accesses the sites that have nothing to do with the ADS.
So, for me, the sweet spot lies between 300k-500k.

Want To Have A Look at My Exact configuration ?

All the files relevant to this project will be upload to my git. Feel free to have a look.
Let me know if you have any suggestions for me or if there is something better we could have done.

Click here to check out the configuration files on GIT

Have Questions?Feel Free to Reach Me