Sei sulla pagina 1di 12

instructables

PiHole Ad Blocker With 3.5" Display

by Puffball101961

Welcome to my tutorial on how to create a really Technically this is optional if you don't want a case,
awesome ad blocker for your whole network! The but it is highly recommended.
Raspberry Pi runs software known as Pi-Hole and
PADD to block ads and display statistical data such as - Ethernet Cable, Used to provide faster internet to
the Pi-Hole's IP Address and the amount of ads the Pi
blocked.
- Router, To Connect Your Pi To
Supplies:
- Raspberry Pi Power Supply, I Recommend the o cial
You Will Need:
Raspberry Pi power supply, but any USB power supply
- Raspberry Pi 3/4, Either will do, and it can be the +
that can supply 5V at at least 2.5 Amps should be ne.
variant if you choose.
- A Windows PC, The software used in this instructable
- 3.5" Raspberry Pi Display, I found a cheap one on
may have equivalents for Mac and Linux, but i'll be
EBay for around $20 AUD.
covering the Windows side.

- A Reliable 8gb Micro-SD Card, I Used a 16gb SanDisk


- A Micro-SD to USB Adapter, Used to connect the SD
card because it was what I had around and I have had
card to your computer. Optional if your computer
good luck with it in the past.
already has a slot.

- A 3D Printer or Access To A 3D Printing Service,

PiHole Ad Blocker With 3.5" Display: Page 1


Step 1: Preparing the SD Card for the Pi

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

- S D Ca rd Fo rm a t t e r, It ca n be do w nlo a de d f ro m s dca rd. o rg ' s w e bs it e .

- Et che r, Us e d t o a s h t he Ca rd. Yo u ca n a ls o us e W in32D is kIm a g e r ins t e a d if y o u pre f e r.

- T he L a t e s t Ra s pbia n Lit e Im a g e , M a ke s ure t o e xt ra ct t he . z ip y o u g e t

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 nished you can close out of SD Card Formatter

Next we need to ash the card. Open Etcher and click the blue button that says 'Select Image' and browse to nd
the .img le 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 con rmed 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 wi . Open File Explorer and click on 'boot' on the left side. You should
be presented with a list of les. Right click and create a new text document, then name it ssh and remove the .txt
extension at the end. No t e , y o u w ill ha v e t o ha v e ' Sho w File Ext e ns io ns ' e na ble d in o rde r t o do
t his . Click Yes and an empty le 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 le,
substituting your wi details in:

PiHole Ad Blocker With 3.5" Display: Page 2


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 nished preparing the card!

PiHole Ad Blocker With 3.5" Display: Page 3


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:

- PuT T Y, w e a re g o ing t o us e t his a s a n s s h clie nt .

Before we connect to our Pi, we need to nd the IP Address of it. The simplest way to do this is to login to your
router using it's IP and nd a device name 'raspberrypi'. Search the instructions of how to do this for your router
and the routers password, as all routers are slightly di erent. 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
PiHole Ad Blocker With 3.5" Display: Page 4
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 o 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 t.

After that you need to install the drivers for your display. This is di erent depending on the display, but in my case I
have a display that runs o Waveshare drivers perfectly. Because this is di erent 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.

PiHole Ad Blocker With 3.5" Display: Page 5


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 le executable:

sudo chmod +x padd.sh

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

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

PiHole Ad Blocker With 3.5" Display: Page 6


PiHole Ad Blocker With 3.5" Display: Page 7
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 with the IP displayed on your Pi, under IPv4 address.
you can actually see the result of your hard work. Do this for all of the DNS IP's including Secondary,
Login to your router through its IP Address, again not Backup, etc. Apply the changes, and depending on
covering it because it is di erent for every router, and your router you may need to reboot the router.
nd the DNS con guration setting. If your router does
not have this option (like mine) proceed straight to Once setup your whole network will be using Pi-Hole
Step 6. Once you have located the DNS Server Options as it's DNS server, so any ad tra c will be blocked.
you will need to replace the Primary DNS server IP

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

PiHole Ad Blocker With 3.5" Display: Page 8


This method should be used if your router doesn't https://serverguy.com/kb/change-dns-server-setting...
allow changes to the DNS server or if you just don't
want everyone on your network on the same Pi-Hole. iO S (iPho ne ):

The Method Is Di erent For Every Device: Open Settings


W indo w s 10 :
Click Wi , and the 'i' next to your connected network
Open Control Panel and click Network and Internet
Scroll down to DNS and click on Con gure DNS
Click Network and Sharing Center, Change Adapter
Settings, right click on your network and click Click Manual, remove the existing DNS server IP's and
Properties put in Pi-Hole's DNS IP

Find Internet Protocol Version 4, double click and click Andro id:
Use the following DNS server and type the Pi-Hole
DNS IP in both elds. Go Back to the Properties List. Open Settings

Find Internet Protocol Version 6, double click and click Click on Wi , and forget the network you are currently
Use the following DNS server and type the Pi-Hole connected to
DNS IP (The IPv6 one this time) in both elds.
Reconnect to it, click Advanced Options, and set IP
Just in case, reboot your PC Settings from DHCP to Static

Linux: Scroll down to nd DNS 1 and 2, and put in your Pi-


Hole's DNS IP in both
https://www.addictivetips.com/ubuntu-linux-tips/ch...

m a c O S:

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 :) !
PiHole Ad Blocker With 3.5" Display: Page 9
If you have any further questions, concerns or issues that arise please leave a comment and I will respond as soon
as I can!

Congratiolations!

Thanks for the great instructable. I had a couple of stumbles but mostly when I raced ahead and
tried to do things out of sequence. I didn't 3D print the enclosure but adding the screen so you can
check status without using the pihole web interface is a top idea. I'm running mine on a short cable
since it's going to live next to my router anyway.

It's so tiny & neat - these photos were taken with it hanging in a guitar hook on my wall.

Nice! Favoriting this one. My partner's been talking about trying something like this for a few
months. :)
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!! :-)

Nice little device. Agreed you don't /need/ a display, but it looks coool :-)

Btw, in step 3 you do not need all the HTML in the wget command. Just saying
wget https://raw.githubusercontent.com/jpmck/PADD/mast...
works fine.

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

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

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.).

PiHole Ad Blocker With 3.5" Display: Page 10


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

You can remove advertisements with a pixelserv script using DD-WRT firmware, but I think I prefer
this one.

https://www.howtogeek.com/51477/how-to-remove-advertisements-with-pixelserv-on-dd-wrt/
Nice project but I do not see advantage to use hw display.
All info you can check on web page of pihole
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.
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?


Hey John, have a look at the pi-hole project here - https://pi-hole.net/ It should answer all your
questions :)
Another place to read an overview about Pi-Hole is https://en.wikipedia.org/wiki/Pi-hole.

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

PiHole Ad Blocker With 3.5" Display: Page 11


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.
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.
also curious about this!

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.
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
Adafruit offers good information regarding how this works: https://learn.adafruit.com/pi-hole-ad-pitft-
tft-detection-display?view=all
Great project! I'll make it very soon!!!

Nice job on your project and your first Instructable :D

Thanks! I really appreciate it. :)

PiHole Ad Blocker With 3.5" Display: Page 12

Potrebbero piacerti anche