PiHole Ad Blocker With 3.5" Display

36,025

362

34

Introduction: PiHole Ad Blocker With 3.5" Display

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.

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.

Thanks SO Much for Voting for My Instructable for the Raspberry Pi Contest, I Got Second :) !

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

Second Prize in the
Raspberry Pi Contest 2020

1 Person Made This Project!

Recommendations

  • Microcontroller Contest

    Microcontroller Contest
  • Automation Contest

    Automation Contest
  • Make it Glow Contest

    Make it Glow Contest

34 Comments

0
Burdennn
Burdennn

Question 4 days ago

Ive got Pihole working but my touchscreen is only is showing a blank screen, anyone have any ideas? I noticed after installing padd, the second to bottom line says 'header missing' so I'm not sure if that has anything to do with it?
Thanks

20210214_150056.jpg
0
joefoxman
joefoxman

3 months ago

This is awesome. Thanks for the great job and awesome app. Super easy to setup and install.

0
brutaltim001
brutaltim001

8 months ago

What size Raspberry Pi 4 should I get for this project; 2, 4, or 8gb?

0
Puffball101961
Puffball101961

Reply 8 months ago

A 2gb Pi 4 will be fine for this project, I run it off a Pi 3 with 1 gb of ram and it works well.

0
Cujo_CH
Cujo_CH

10 months ago

I added a 3.5" TFT touchscreen and it works but the first 4 lines (Stats and above) aren't on the display. Does anybody know what I did wrong?

0
Puffball101961
Puffball101961

Answer 10 months ago

The same thing happened to my Pi-Hole after I updated it. I’m not sure why it does it but i suggest you reinstall Pi-Hole to see if it fixes the problem.

0
Cujo_CH
Cujo_CH

Reply 10 months ago

I didn't updated my pihole. I installed the dispaly first time. So I don't see why a reinstallation of pihole should help here. Specially as the lines are there only not on the display. For me it looks more as there are more lines than place on the display. Did you do a reinstallation? And fixed that the issue?

1
OldSkiBum
OldSkiBum

9 months ago

Built one of these but did not add the display. The web interface gives much more info. My router allows me to specify the URL for the DNS servers (two). If I just replace one of them with the address of the Pi-Hole (keeping the other ISP-supplied address), the router alternates between them. If I replace BOTH with the address of the Pi-Hole, ALL requests go through the Pi-Hole, but this makes the Pi-Hole a non-redundant point of possible failure (i.e. if USB input power drops). So, to do this right, one should probably make TWO of the Pi-Hole devices and run them from two different USB power modules, which I have now done. I also made a donation recognizing a very nice piece of software.

1
MIHegazy
MIHegazy

11 months ago

Congratiolations!

1
jessyratfink
jessyratfink

11 months ago

Nice! Favoriting this one. My partner's been talking about trying something like this for a few months. :)

0
Puffball101961
Puffball101961

Answer 1 year 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

1 year 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 1 year ago

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

1
MikeG363
MikeG363

1 year ago on Introduction

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

2
Meso47
Meso47

1 year 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 year ago

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