PiHole Ad Blocker With 3.5" Display

18,754

232

23

Introduction: PiHole Ad Blocker With 3.5" Display

About: Hello, I’m a maker and love to eat tacos!

Welcome to my tutorial on how to create a really awesome ad blocker for your whole network! The Raspberry Pi runs software known as Pi-Hole and PADD to block ads and display statistical data such as the Pi-Hole's IP Address and the amount of ads blocked.

Supplies:

You Will Need:
- Raspberry Pi 3/4, Either will do, and it can be the + variant if you choose.

- 3.5" Raspberry Pi Display, I found a cheap one on EBay for around $20 AUD.

- A Reliable 8gb Micro-SD Card, I Used a 16gb SanDisk card because it was what I had around and I have had good luck with it in the past.

- A 3D Printer or Access To A 3D Printing Service, Technically this is optional if you don't want a case, but it is highly recommended.

- Ethernet Cable, Used to provide faster internet to the Pi

- Router, To Connect Your Pi To

- Raspberry Pi Power Supply, I Recommend the official Raspberry Pi power supply, but any USB power supply that can supply 5V at at least 2.5 Amps should be fine.

- A Windows PC, The software used in this instructable may have equivalents for Mac and Linux, but i'll be covering the Windows side.

- A Micro-SD to USB Adapter, Used to connect the SD card to your computer. Optional if your computer already has a slot.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Preparing the SD Card for the Pi

This is pretty simple, but before we flash the SD here is the software you will need :

- SD Card Formatter, It can be downloaded from sdcard.org's website.

- Etcher, Used to flash the Card. You can also use Win32DiskImager instead if you prefer.

- The Latest Raspbian Lite Image, Make sure to extract the .zip you get

Ok, we have gathered our software, lets get started.

First we need to Format the SD Card. We do this by opening SD Card Formatter, Plugging in out SD card and choosing it from the list at the top of the window. Make sure you select your SD card, not another drive. Ensure there is nothing important on the card as everything will be deleted on the card. Once you are ready click 'Format'. It shouldn't take too long to complete. Once it has finished you can close out of SD Card Formatter

Next we need to flash the card. Open Etcher and click the blue button that says 'Select Image' and browse to find the .img file you downloaded earlier and select it. Next your SD card should already be selected by default, but if it isn't just change it by clicking the button. Once you have confirmed that all the selections are correct, click 'Flash!'. This will take a few minutes, and once it is done you can close out of Etcher.

Finally we need to enable ssh and connect to wifi. Open File Explorer and click on 'boot' on the left side. You should be presented with a list of files. Right click and create a new text document, then name it ssh and remove the .txt extension at the end. Note, you will have to have 'Show File Extensions' enabled in order to do this. Click Yes and an empty file called ssh should be present. Next we need to create a text document again, but name it wpa_supplicant , replacing the .txt with .conf. Right Click it and select edit and paste this text into the file, substituting your wifi details in:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="WIFI_SSID"
scan_ssid=1
psk="WIFI_PASSWORD"
key_mgmt=WPA-PSK
}

Make Sure to Save The File Once You Are Done!

Eject the SD Card, Put it in the Pi and you have finished preparing the card!

Step 2: Installing Pi-Hole Through SSH

Now we are going to install the holy grail of software, Pi-Hole.

Again, we need some software to continue, so download this:

-PuTTY, we are going to use this as an ssh client.

Before we connect to our Pi, we need to find the IP Address of it. The simplest way to do this is to login to your router using it's IP and find a device name 'raspberrypi'. Search the instructions of how to do this for your router and the routers password, as all routers are slightly different. Once you have the IP Address of it open PuTTY and in the Host Name box type in your IP Address, then click 'Open'. A Warning will pop up, just click Yes and you will be brought to a black terminal with a login. Type the username 'pi' and the password 'raspberry'. Once logged in successfully you should be brought to a command line with pi@raspberrypi. Now you want to paste in the following code:

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

It should start downloading the installer and then automatically start installing.

It will present you with a series of screens, in which you will press ok, or yes, and for the Upstream DNS server choose Google.

If you want to be able to use the Web Interface more easily we can change it's password, by typing

pihole -a -p

In the terminal.

Pi-Hole should now be installed! Of course you could just use Pi-Hole without the display, but whats the fun in that?

Step 3: Installing PADD and a 3.5" Display, and 3D Printing the Parts

Now we are going to install PADD, which displays our Pi-Hole stats on a display. This step is a little more terminal based though, but don't be turned away, it is very simple.

Before we install PADD, we need to install our Display. Ensure the Pi is off and Disconnected from power and attach the screen as shown in the picture, and if connected correctly the display should line up with the rest of the Pi.

The 3D Printed Case Can Be Found Here: https://www.thingiverse.com/thing:1895374

Now You Need to attach the front piece to the USB and Ethernet Ports, as shown in a picture. Then just slide the package into the sleeve and it should all come together nicely. You can close it permanently with some glue, but I left it loose because it was already a pretty tight fit.

After that you need to install the drivers for your display. This is different depending on the display, but in my case I have a display that runs off Waveshare drivers perfectly. Because this is different for every display I won't show how to do it here, but a quick search on YouTube should give you your answer.

Once you have the display working, so when you boot the pi it displays the terminal on the Pi we are ready to install PADD.

To Install PADD we need to run the following commands in the terminal:

cd ~
wget -N https://raw.githubusercontent.com/jpmck/PADD/master/padd.sh

Once it has downloaded we need to execute this to make the file executable:

sudo chmod +x padd.sh                                             

Now we need PADD to execute on startup. We do this by modifying a special file.

sudo nano ~/.bashrc

Then Using the down arrow on your keyboard scroll down to the very bottom and paste in this:

# Run PADD
if [ "$TERM" == "linux" ] ; then
  while :
  do
    ./padd.sh
    sleep 1
  done
fi

Then Reboot Your Pi With

sudo reboot

Step 4: Changing the PADD Size From Regular to MEGA

By Default the PADD display will only be at the Regular Size, not utilising all of the screen, but we can change that!

First we need to SSH into our Pi, this was covered earlier. Once you are at the terminal type:

sudo dpkg-reconfigure console-setup

A Menu Should appear with many options, we need to select UTF-8, or if you know what the other encoding settings are give them a try if you want. Next select Guess Optimal Character Set, then select Terminus and then 6x12. Once you have followed these steps reboot with

sudo reboot

Step 5: Configuring Your Router for Network Wide Ad-Blocking

Now this is the step where it all comes together, and you can actually see the result of your hard work. Login to your router through its IP Address, again not covering it because it is different for every router, and find the DNS configuration setting. If your router does not have this option (like mine) proceed straight to Step 6. Once you have located the DNS Server Options you will need to replace the Primary DNS server IP with the IP displayed on your Pi, under IPv4 address. Do this for all of the DNS IP's including Secondary, Backup, etc. Apply the changes, and depending on your router you may need to reboot the router.

Once setup your whole network will be using Pi-Hole as it's DNS server, so any ad traffic will be blocked.

Step 6: Configuring the DNS Server on a Selection of Devices

This method should be used if your router doesn't allow changes to the DNS server or if you just don't want everyone on your network on the same Pi-Hole.

The Method Is Different For Every Device:
Windows 10:

Open Control Panel and click Network and Internet

Click Network and Sharing Center, Change Adapter Settings, right click on your network and click Properties

Find Internet Protocol Version 4, double click and click Use the following DNS server and type the Pi-Hole DNS IP in both fields. Go Back to the Properties List.

Find Internet Protocol Version 6, double click and click Use the following DNS server and type the Pi-Hole DNS IP (The IPv6 one this time) in both fields.

Just in case, reboot your PC

Linux:

https://www.addictivetips.com/ubuntu-linux-tips/ch...

macOS:

https://serverguy.com/kb/change-dns-server-setting...

iOS (iPhone):

Open Settings

Click Wifi, and the 'i' next to your connected network

Scroll down to DNS and click on Configure DNS

Click Manual, remove the existing DNS server IP's and put in Pi-Hole's DNS IP

Android:

Open Settings

Click on Wifi, and forget the network you are currently connected to

Reconnect to it, click Advanced Options, and set IP Settings from DHCP to Static

Scroll down to find DNS 1 and 2, and put in your Pi-Hole's DNS IP in both

Step 7: Updating Your Pi-Hole

Updating Pi-Hole is very easy. To see if your Pi-Hole has a new update available in the top right of the display it will say Update Available! To update simply SSH into your Pi-Hole and run:

pihole -up

And Your Pi-Hole should Update!

Step 8: All Done!

If you followed all the steps correctly you should have an amazing ad blocker which is really good at what it does. If you enjoyed following my tutorial please consider voting for my Instructable for the Raspberry Pi Contest!

If you have any further questions, concerns or issues that arise please leave a comment and I will respond as soon as I can!

Raspberry Pi Contest 2020

This is an entry in the
Raspberry Pi Contest 2020

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    23 Discussions

    0
    Puffball101961
    Puffball101961

    Answer 10 hours ago

    Does your screen have a hdmi connector? If it does connect the hdmi to your Pi and the gpio connectors to the pis gpio. If the display just has gpio connectors connect the display to the pis gpio.
    If the display has hdmi drivers usually aren’t required.
    Usually displays like this use waveshare drivers. A quick search of ‘waveshare display driver installation’ should get your answer.

    1
    Scruffy_Nerfherder
    Scruffy_Nerfherder

    12 hours ago

    I just did this for our office as a VM using Raspberry Pi Desktop (instead of the console-only Pi) and it works *exceptionally* well! The only caveats were that I had to set the Pi IP within our DHCP server's Scope to be doled out as the new internal DNS IP *and* I had to turn on Conditional Forwarding in Pi (via the web GUI) to resolve our internal DNS requests so the clients could connect to Exchange and other internal resources. I am more pleased than you could possibly imagine. I'll probably set up VM's at our other sister companies, and corporate office, to do the same thing.

    It's so bizarre, going to websites now and not seeing all those ads that used to populate and litter the pages. It looks almost naked without them.

    Fantastic write-up! Thanks so much for this little gem, Puffball!! :-)

    Pi-Ad-Blocker.png
    0
    Puffball101961
    Puffball101961

    Reply 19 hours ago

    Sorry, it was the weird Instructable formatting that messed it up. It should be fixed now :)

    1
    MikeG363
    MikeG363

    1 day ago on Introduction

    Love it, now how do I get rid of all the spam junk on my email?

    2
    Meso47
    Meso47

    1 day ago

    There’s even more to Pi-Hole than blocking ads - it can also help your home network’s security posture but it’s important to protect it too, keep it updated, etc. There are some good guides on securing a Pi (https://www.raspberrypi.org/documentation/configuration/security.md and https://blog.f-secure.com/secure-your-raspberry-pi-and-potentially-your-home/ etc.) and malware-specific blocklists in Pi-Hole can help keep software or accidental link clicks from reaching out to bad sites to short circuit what might have otherwise been a successful attack (https://isc.sans.edu/suspicious_domains.html etc.).

    1
    auto13142828
    auto13142828

    1 day ago

    Might not lists curated based on crowdsourced data also block sites based on political bias?

    1
    PeterP137
    PeterP137

    1 day ago

    Nice project but I do not see advantage to use hw display.
    All info you can check on web page of pihole

    1
    Puffball101961
    Puffball101961

    Reply 1 day ago

    The display isn’t really nessecary, I just think it looks cool to be able to see all the stats of it at a glance.

    4
    JohnD818
    JohnD818

    1 day ago

    Interesting project.

    I have a few questions;

    - Do you mean by "blocking ads" that the clickbait ads that, for example, I see throughout your instructable will be removed?

    - How are ads detected? All network traffic routed through the Raspberry Pi? Will that cause a bottleneck and network slowdown?

    - Might there be false positives?

    0
    86webbmartin
    86webbmartin

    Reply 1 day ago

    Hey John, have a look at the pi-hole project here - https://pi-hole.net/ It should answer all your questions :)

    2
    The1Bill
    The1Bill

    Reply 1 day ago

    Without assuming anybody's prior knowledge of how the internet infrastructure works, I will start with a primer.

    When you type in a url like instructables.com into your browser, a query is sent to a special kind of server that converts the [domain] name to its address on the internet (its IP address). This server is called a DNS server (standing for Domain Name Service). The IP address is then passed to whatever asked for the query (like your browser, a phone app, or a Smart TV) which then uses the IP address to get the content directly.

    When you are looking at a website, different components of the website come from different places. The clickbait ads that you see come from a service that specifically exists to sell and serve ads, and are not from instructables.com.

    What the PiHole does is stand between you and your DNS query, acting a bit like a bouncer at a club checking against a list of known ad serving domains. Any queries that are not on the list go right through and any queries that are on the list go no further than the PiHole. Even if the PiHole is not blocking anything, this will have a negligible impact on performance, as only the DNS query itself is passing through the PiHole. Overall network performance will actually be improved as all throughput related to ad content is blocked before the request even leaves your home network.

    To phrase it a bit more succinctly, the only traffic that passes through the PiHole is DNS lookups and not the entirety of the content that flows from the internet.

    Where does the blacklist come from and how is legitimate traffic allowed through? Well, there are many lists that can be selected when the PiHole is being set up. The lists are typically curated based on crowdsourced data. A good source of these lists can be found at firebog.net (I have no connection to the site, but I have updated my own PiHole to use some of the lists there). That may not sound like the most reassuring of answers, but I have actually never come across legitimate content that I have wanted to get to that I could not reach through the lists I have on my PiHole yet.

    I hope this answers your questions. I really love my PiHole (though I never thought of putting a screen on it!) and highly recommend it to anybody who dislikes ads and enjoys tinkering a bit.

    1
    dhagenson
    dhagenson

    Reply 1 day ago

    The pi-hole website (https://pi-hole.net/) does a pretty good job of explaining how everything works, but I can answer your questions.
    Yes, when viewing Instructables on your home network with pi-hole running you will not see any ads. And this applies to all devices on your home network. We have Roku devices and we don't see the huge advertisement on the main menu screen anymore.
    Network traffic does NOT go thru the Raspberry Pi, the Pi simply becomes the DNS server for your home network. A DNS server converts a website/server name (like Instructables.com) into an IP address (like 151.101.1.105) that is needed to find the website/server on the internet. Normally, your router is setup to use your ISPs DNS server or Google's DNS. In step 5 of the Instructable, you change your router to use the Pi as your DNS server.
    Pi-hole comes pre-loaded with a ton of known servers used for ads. When a website tells your browser to get an ad from one of those known servers, Pi-hole basically tells your browser that the server couldn't be found, so the ad doesn't load. This actually makes your network faster because the ads are not downloaded from the ad server.
    There can be false positives, but Pi-hole has a web interface that is reachable from any browser on your home network where you can add to a 'Whitelist' of websites to NOT block, and a 'Blacklist' of additional sites you would like blocked. I had to add 'weeklyad.target.com' to my whitelist so we could view the weekly ad from Target. You can also use the blacklist as your own personal website blocker. You could add 'facebook.com' to your blacklist to block access to facebook.

    0
    JoeM114
    JoeM114

    Reply 1 day ago

    also curious about this!

    1
    DmitriyI4
    DmitriyI4

    1 day ago

    IMHO screen is optional and not really needed. DIY describes how to make caching DNS server on raspbery which has black and white lists of domains and web based interface. also it has built in dhcp server. nice addition for the home network.

    2
    RMRS
    RMRS

    1 day ago

    I have a PiHole setup and my router doesn't allow to change the DNS server. So, i've disabled the DHCP server on my router and enabled the DHCP service on PiHole.
    With this configuration, i don't need to change the DNS on my devices, PC, MAC, android, etc.
    Anyway, nice job.
    On mine, i just need to connect the LCD (i have one) and install PADD, that i'm going to make asap