Shut your Pi-Hole

What is Pi-Hole and why should you use it? Pi-Hole is a nifty application that was written to help declutter your browsing by removing ads on from the sites you’re browsing.  There are other tools that do this such as ad blocker browser extensions but the real beauty of Pi-Hole is that once it’s setup it’s pretty much worry free and sites have more difficulty detecting it.  Now, a disclaimer, I worked for a digital marketing agency that helped brands improve their SEO and buy targeted ads.  I know that there are content creators out there that rely on this income and businesses that really believe they have a useful message to deliver to you.  Where I finally drew the line was when I was browsing and constantly getting full screen overlays with ads or ads taking up a good 50% of the real estate on a site.

Sounds too good to be true?  Well I had a Raspberry Pi model B hanging around – they’re not really that powerful and since the 2’s and 3’s came out there isn’t too much use for them.  The way Pi-Hole works as it acts as a DNS server with lists of known ad domains.  You set your network to look to the Pi-Hole to get the DNS info and if it’s looking for a known ad, it’s replaced with basically an empty good response leaving a blank space where the ad would be.  Since the DNS query is cached on the Pi and such a trivial operation, the Pi has no problem with the workload.

So, how much of a pain was it to set up?  Incredibly easy, just follow these 5 simple steps to ad free browsing (doctors don’t want you to know step #3!)

Step 1 – Install your OS

I decided to use Raspbian Jessie Lite to keep as much clutter as possible off of the pi.  While suprising on what they can do so inexpensively, Pi’s are hardly beefy workhorses so I wanted to have a little running on the machine as possible.  I use Windows for my primary machines so I needed to use win32diskimager to copy the image to my sd card.  If you plan on setting the rest of your Pi up headless, be warned that you now need to include an empty file named ssh on the root of the SD card in order for the SSH service to be enabled on boot.

Step 2 – Setup and Update

After popping in the SD card, I connected my Pi to my network and was able to ssh into it by using the default hostname raspberrypi.  Once on, I like to go though the raspi-config and update my locale and expand my drive to the full SD card.  The next time is to do and apt-get update and apt-get upgrade to ensure all of the packages are up to date.

Step 3 – Install Pi-Hole

The Pi is all updated and ready to roll, so now all that needs doing is to install Pi-Hole.  The process is so simple, it’s the subheadline of their website

That’s right, once you’re logged into the pi, all you need to do is run sudo curl -L https://install.pi-hole.net | bash  Sure piping a website directly into bash could be asking for trouble, and if you’re the cautious type there are instructions on how to view the code or do a more attended install.

Once the install is finished you’ll see this message. Keep note of the password – you won’t be able to view it again, but there is a command that can be run to reset it.

Step 4 – Update your DNS servers

To do this, I updated my router with the DNS servers it should provided to clients with DHCP leases.  I set the primary DNS  server to be my pi hole, and the secondary and tertiary to be Google’s (8.8.8.8 and 8.8.4.4) in case the Pi-Hole is unavailable.

Step 5 – Enjoy your Ad-reduced browsing

Pi-Hole isn’t perfect, but you’ll know if it’s running.

Before:

After:

 

Also, if you ever need to administer the server, there is a handy-dandy web backend for it.  Just browse on over to http://<your-pi-hole>/admin and use that generated password from step 3 to login.  I’ve only had mine running for about a day and you can see the total vs blocked graph below to see how effective it’s been.

By | 2017-08-19T17:57:16+00:00 December 22nd, 2016|Categories: Raspberry Pi|Tags: |

About the Author:

Jason is a Magento Certified Solution Specialist and has been working with Magento for a few years - both with Enterprise and Community Editions.