In this blog article, I'll explain how to install Hole on the Raspberry Pi, the network-wide ad blocker for your home network devices.
Prepare the Raspberry Pi Hole installation
I do the whole thing from the terminal from the Raspberry Pi. Of course, the Raspberry Pi Hole installation also works if you log in to your Raspberry Pi via SSH using "ssh pi@ip-address" via Mac Terminal or remotely via PuTTy (PC). The steps remain the same.
First, let's get the Raspberry Pi up to date and download the updates. I assume that you can already install the Raspberry Pi. Now enter the command 'sudo apt - get update' followed by Enter. This will take a little while. When that's done, run the command 'sudo apt - get upgrade' to install the new versions of the software.
Now we want to download Pi-hole. For that, next we enter this command on the terminal 'curl - sSL https://install.pi-hole.net | bash'. With this we download the script that is behind this address and the command bash executes this script for the Raspberry Pi Hole installation afterwards.
Now all packages for Pi-Hole will be installed automatically. You will even see a nice graphical interface for this. After that you will be guided through the Raspberry Pi Hole installations. Confirm all further prompts with Enter, so you can continue with the actual installation. Now you will see the hint that Pi-Hole is free and open source.
Pi Hole network configuration
After that you will see the hint that the Raspberry Pi needs a static IP address. Now it is usually the case that routers assign new IP addresses to devices from time to time. You should find this in your router settings, otherwise just search for your router model and look for static IP addresses in the search engine.
Now you have to choose where the network traffic should go through, either through the ethernet port which has the internal name eth0 or through the wlan port wlan0. I have connected my Raspberry Pi via WLAN, so I select wlan0. Now you have to select a DNS provider, which will be used later for DNS requests. You should be aware that each DNS request always transmits certain data and that this data is visible to the provider.
That means you can choose one of the known DNS providers. I do it like this and enter a "Custom" DNS server. The DNS server address is 18.104.22.168. Behind this IP address is a DNS server from the Chaos Computer Club, which anonymizes all DNS requests.
You can also choose one of the preset DNS servers. You can confirm the whole thing with Enter. Now you will be asked again, are the IP addresses correct? Confirm with "Yes". Now so-called blacklists are to be downloaded, which can recognize the advertisements in the Internet traffic immediately. That is, they are lists of addresses that typically play out advertising.
The best thing to do is to download all lists. You can choose later if you want to deselect any of them. Now the question is, how to block advertising requests, either IPv4 or IPv6. It is best to choose IPv4 and deselect the IPv6 version. Usually all IP addresses run on version 4. Afterwards you will be asked again if these Raspberry Pi Hole network settings are correct. After that the IP address of the Raspberry Pi should be recognized correctly. You confirm this again with Ok. Now there is another hint. Confirm this also with Ok.
Pi Hole User Interface
In the next step you will be asked if you want to access the admin interface via the browser and if you want to install it. Confirm this with Ok. This is a handy thing and a good way to control Pi Hole very easily. And we also log the queries, then you always have a good overview of how much advertising was filtered out. But you can turn that off later.
Now we can specify which mode we want to set regarding data protection and privacy. Here you also select everything to have an overview of what the Raspberry Pi-hole specifically does. Otherwise, that's it for the whole Raspberry Pi Hole installation. The complete setup is finished. Now you will see the password you have to use to log in to Pi Hole on the web interface. It is best to write down the password or copy it to your password manager.
Raspberry Pi Hole Installation Completion:
The Raspberry Pi Hole installation is now complete. You can now access the Raspberry Pi or Pi Hole web interface through your browser. To do this, simply enter the Raspberry Pi's IP address in the browser followed by /admin Then the following web interface will open. You can also try http://pi-hole/admin.
Now we want to log into the web interface. For this we go on the web interface page to Login and enter the password that was shown to you at the end of the installation. Now you have access to all the settings that can be made. We can now edit whitelists etc. We now have access to all the Pi Hole settings we need.
Now we still need to make sure that we switch the Raspberry Pi between each computer, tablet and smartphone so that any DNS request is filtered and ads are blocked. To do this, log into your router and re-set the DNS address for DNS requests from your router to the Internet. The new DNS address in your router must be rewritten to the IP address of your Raspberry Pi, so that all DNS requests from the router can first be filtered through your Raspberry Pi hole.
How to change the DNS settings on your router can be found in the manual of your router. Before you change the DNS settings, go to a site of your choice with a lot of advertisements to compare it as soon as Pi-Hole is activated.
When this is done, we want to see Pi-hole in action. For this you can e.g. visit the site of T-Online, because it has relatively much advertising. Do you see the difference to before? When I reload the page, the web traffic should now go through the Raspberry Pi Hole. And as you can see for yourself, the ads are gone. That means the pi-hole has struck and removed the ads.
* = Affiliate Link (raspi-config.com) is participant of the affiliate program of Amazon USA, which is designed to provide a commission for websites to earn advertising fees by placing ads and links to Amazon.com).