DEV Community

itsmenilik
itsmenilik

Posted on

Down The Hole Ya Go

INTRO

YouTube ad sense is a big portion of it's profit stream. Soooooo we are going to stop that! Well not really. However, we can block all of their ad's from reaching us. A while back I set up a Pi Hole and I thought I'd explain my journey into the setup. Pi Hole is a DNS filtering tool that can be configured to block advertisements, trackers, malicious websites, and malware.

We are going to do this with the help of a Raspberry Pi.

Alt Text

WHY THOUGH!

Traditional ad blockers are set up on a web browser. They typically analyze the data that's coming from your visited web page and either replace or remove advertisements. This works great for that one browser. I ran into a problem where everyone in my house doesn't have this installed or even knows what an ad block extension is. Pi Hole is a great solution as it can block ad on all of the devices within my house (iphones, androids, and computers).

Basic Concept

Let's say you launch a mobile game on your phone. As it's launching, all the assists are loading (texters, dialog, music, etc). At the same time, a request is being made by the game's url DNS server, which is managing the ads for that application. Your router then looks up that url and replies to your phone with a specific ip address that contains the ad. Instead of storing ads to application this method allows advertisers to dynamically serve individually tailored ads.

Alt Text

Pi Hole can block this process, or stand in between the DNS server and your device. Pi Hole will contain a blacklist of sites to block. If your device is attempting to retrieve information from a blacklisted site, then it would reply to your device with an unspecified address. Which would not show the ad on your device.

Alt Text

Setups

This involved the following steps

  1. Install Raspbian on a micro sd
  2. Change the default passwords
  3. Configure a static IP for my raspberry pi
  4. SSH into the pi (I didn't want to connect a monitor to my pi)
  5. Run the one line install command on the my raspberry pi terminal
  6. Get to the networking selection and set up the default blacklists

Whats cool about these steps is that I was exposed to my terminal more than usual!.

Alt Text

All that's left if the connect the the ip address and we are in!

Finished Product
At the end of it, you get this dashboard where you can manage your blacklist whitelist, devices, and certain statistics :

Alt Text

Overall all, this is a dandy project. If you are interested in in getting your hands dirty and want to setup your own pi hole here is the link Pihole

Top comments (0)