08 Jan 2022
- Comments (0)
Have you heard about PiHole before? If you have then you already know that this little software can help you fight ads and trackers on the internet and you can jump straight to the tutorial. But if you haven't heard about it before, then we will here give you a brief explanation of what PiHole is and how it can help you and your family stay safe online.
What is PiHole?
We have all tried before, we search something on Google, and now all of a sudden we get harassed with ads from various websites selling these products. The ads show up almost everywhere and it is not only products that you have searched for yourself that show up. Also, products that your spouse or even children search for show up in your Facebook newsfeed or YouTube videos.
Luckily there is a way to stop this, and the only thing it requires is to turn off the internet on all of your devices completely... I'm just kidding. There is another way and the magical software is called PiHole.
PiHole is a DNS sinkhole that will check all of your DNS requests and check that they aren't listed on the blacklist. If the DNS request is listed on the naughty list it will be denied and it won't get access to the internet. This way all the tracking requests, ads, malware, etc will be stopped before they leave your network and the receiver won't get your data.
Most of the products we buy today have a tendency to analyze the way we use them and send back information to the manufacturer. In many ways, this can be a good thing, but if you like your privacy it is definitely a bad thing. Wanting your privacy doesn't have to be because you have something to hide. You probably also don't want people to look at you when you change underwear, right? With PiHole you can stop these products when they try to "call home" to rat about your usage.
Another use case of PiHole is also to secure your home network. If you have children and don't want them to be able to access porn sites, torrent sites, or anything else illegal, then you can simply blog the websites from PiHole, and then no one will be able to access the websites.
PiHole is very open, and you as a user decide how advanced and strict your PiHole setup should be. You can add your own lists to the blacklist and you can add lists that have been developed over time. The current lists we use at SustainableWWW contain between 250.000 and 260.000 blacklisted domains ranging from ads to malware and crypto mining.
If you are interested in knowing more about PiHole, then you can read their documentation here at PiHole's own website: https://docs.pi-hole.net.
How to install PiHole on a Raspberry Pi 4B
To do this tutorial you need to have a fully functioning Raspberry Pi 4B running Raspbian on either an SD card or external hard drive. If you haven't done this yet, please make sure to do that before continuing with this tutorial.
Step 1: SSH into your Raspberry Pi
To be able to install PiHole on your Raspberry Pi, then we need to SSH into it using the console on your Windows, Linux, or Mac computer. The first thing you need is to figure out which IP addresses or Raspberry Pi has been given on your network and then you type the following:
In the example above I am going to SSH into the Pi using the user "pi" and the address that the Raspberry Pi has on my network. The IP address might be different on your network.
The standard password (unless you have changed it) will be "raspberry". Once you have typed the password you will get access to the Pi directly from your console.
Step 2: Update and Upgrade the Raspberry Pi
Before we install PiHole we need to make sure your Raspberry Pi is updated and upgraded. This can be done by running the following command in your console (Make sure you are connected to your Raspberry Pi before doing this).
sudo apt-get update
Once your device is done updating the packages you can run the script below to upgrade your pi and apply the new updates.
sudo apt-get upgrade
Once the process is done upgrading your Raspberry Pi, you will be ready to jump to the next step where we will assign your device a static IP address.
Step 3: Assign a static IP to your Raspberry Pi
Before installing PiHole we also need to assign your Raspberry Pi a static internal IP address. This will make sure your device always gets the same IP address whenever you connect it. If you don't assign a static IP address you won't be able to use PiHole or the internet next time the address changes.
Normally you can assign a static IP address to devices through your router's settings. Depending on the brand and device it can be done through an app or by an internet page. Once your device has been assigned a static IP you are ready to jump to the next step.
Step 4: Install PiHole on your Raspberry Pi
Installing PiHole on your Pi is very easy and it actually only takes one command that you copy/paste into your console. Once this is done it will open an installer that will guide you through the installation.
To begin the installer, please run the following line in your console:
curl -sSL https://install.pi-hole.net | bash
Before you leave the console or do anything else, please make sure to copy the administrator password from the install script once it is done. This password is needed to access the web interface where you can administrate all your PiHole settings.
Step 5: Make your devices go through PiHole
Now that PiHole has been installed on your Raspberry Pi and it is running in the background, then it is ready to check some DNS requests for you. But before this will actually work, we need to either route all your devices at home to PiHole or route your WiFi router to use PiHole. The easiest step is to change the DNS settings on your WiFi because that will make all devices connected to the WiFi router go through PiHole automatically.
To route all your WiFi traffic through PiHole you enter the settings of your router. Somewhere in the settings, you will find a place where you can change the primary and secondary DNS addresses. Add your Raspberry Pi's internal IP address to the DNS settings and make sure there is only one DNS added and click save. Now all traffic should be rerouted through PiHole before it goes to the internet.
If you don't want to route all of your WiFi traffic through PiHole, then you can also do it on the individual devices you wish. To do this, please follow this tutorial that will guide you through how to do it on iOS, Mac, Windows, and Android: https://www.howtogeek.com/167533/the-ultimate-guide-to-changing-your-dns-server/.
Step 6: Access the PiHole web interface to change settings
With the web interface, you can easily change your DNS upstream, add addresses to your blacklist, keep track of which websites are being visited on your network, restart the DNS resolver, and many more things.
To get to the web interface you type in the address that your Raspberry Pi has been assigned and then slash admin: "192.168.100.101/admin". This will display a login screen where you can type in the administrator password you copied from the setup, once that's done you will be taken to the dashboard where you can set up your PiHole DNS sinkhole.
Step 7: Finding the right blocking lists for PiHole
When you have access to your PiHole web interface, then you can add the blocklists you wish to block on your home network. Finding these lists can be hard, and takes a little bit of practice.
To make it easier for you, we have linked to the lists we are using daily. They have been divided into categories so that you can pick the ones you find interesting: https://firebog.net.
PiHole is amazing and in my opinion, everyone should be using it. As mentioned earlier our blacklist contains about 250.000 blacklisted URL's and that means roughly 15-20% of our internet traffic is getting denied. This 15-20% are roughly malware, tracking, and ads that websites try to send to us.
PiHole helps on most or all the ads and tracking in your web browser and most apps, but ads are still showing in some apps such as YouTube and Facebook. We think the reason for this is that ads are being served from YouTube's and Facebook's own domain instead of from an ads provider (At least in the apps).
We would like to hear more about your experience with PiHole and how you have set it up on your Raspberry Pi at home. Please share your thoughts and experience in the comment section below.