How to Set Up Pi-hole on Raspberry Pi to Block Ads and Trackers
The ad-based revenue model has helped online services and publishers to remain functional for years. However, we can’t deny that nasty trackers have made it nearly impossible to keep an anonymous profile on the Internet today. Newfingerprinting techniquesand trackers integrated into app SDKs can easily identify you within a few seconds. Not to mention, ad-heavy web pages eat up crucial resources and slows down the device. So if you have bought a Raspberry Pi to remove all ads from your devices, then this article will help you install Pi-hole. We have detailed how you can set up Pi-hole on Raspberry Pi to block ads and trackers in this article.
Set Up Pi-hole on Raspberry Pi to Block Ads & Trackers
Here, we have explained the steps to set up and run Pi-hole in simple terms. We have used Raspberry Pi 4 Model B in our tutorial, but it will also work on old boards. You can expand the table below and move to the corresponding section with ease.
Install Pi-hole on Raspberry Pi
I am assuming you have already set up your Raspberry Pi. If not, you can follow our tutorial and learn how touse your Windows laptop as a monitor to access and set up your Raspberry Pi, in case you don’t have a separate monitor. Now having said that, let’s move to the steps.
-
First of all, connect the Raspberry Pi to your home Wi-Fi network andopen the Terminal. Next, run the below command. It will start installing Pi-hole on your Raspberry Pi.
-
If you are usingPutty or VNCto remotely access the Raspberry Pi, you can run the same command in the Terminal window. For example, here I am using Putty to install Pi-hole through Raspberry Pi’s console.
-
Once the initial steps are done, Pi-hole will take you through the setup screen. Press “Enter” as it displays information regarding Pi-hole. Keep in mind you can only navigate the UIthrough the keyboard. Use the arrow keys and “Tab” to jump between options. And press the “Spacebar” if you want to select an option.
-
After a couple of dialogs, it will alert you that Pi-hole needs aStatic IP Address. Press “Enter” again.
-
Next, choose “wlan0” if the Raspberry Pi is connected through Wi-Fi. And select “eth0” if you are using a wired Ethernet connection.
-
Then, it will ask you tochoose the DNS provider. I usually go with Google’s DNS server, but you are free to choose your own.
-
On the next page, it will show you that Pi-hole is usingStevenBlack’s hoststo block ads. Earlier, there were multiple third-party host files, but nowPi-hole uses a unified list to reduce mismatch. Later on, you can add more host files if you want. So don’t change anything and make sure the list is marked (an asterisk sign will appear next to the list), and hit Enter.
-
After that, choosebothIPv4 & IPv6protocols. You can press the spacebar to mark both options.
-
Next,press on “Yes” to set a static IP addressto your Raspberry Pi. These steps are important to ensure that the IP address does not keep changing.
-
On the “FYI: IP Conflict” page, press “OK“. We will perform a step later to deal with the IP conflict issue.
-
After that,choose “On”and press “OK”. This will allow you to access all the queries in a web interface.
-
Similarly, choose “On” and press “OK” to install the webserver (lighttpd) on your Raspberry Pi.
-
Now if you want to log queries, choose “On” and proceed.
14. On the next dialog box, select “Show everything” and press “OK”. It willlet you monitor all the queries and the IP addressesto know where these requests are coming from. You don’t need to worry about the privacy aspect as everything happens locally on the Raspberry Pi.
-
Now, you are almost done. It will start theinstallation againand will configure Pi-hole according to your preferences on the Raspberry Pi. This step will take considerable time so keep patience.
-
Once the installation is complete, it will show a final screen with all the details. Make sure to note down the “IPv4 address” (it’s your RPi’s IP address), password, & the web interface address. With these details, you will be able to monitor all the queries on your home network. Press “OK” and close the window.
-
Now, open a web browser and enter the web interface address, and hit enter. Basically, open the[IP address]/adminpage. If the dashboard opens up, you have successfully set up Pi-hole on your Raspberry Pi. Click on “Login” in the left pane and enter the password. Now, sign in, and you are almost at the finish line.
Configure Your Router
While everything is set up correctly, you need to change one key setting on your router. You need toredirect all the traffic to the Raspberry Piso that it can filter out all the ads and trackers. Here is how you can do it.
-
Enter192.168.0.1in a web browser on any device in your home network and hit enter. As we all know, it opens the router’s settings page. Now, enter the default credentials for your router and sign in.
-
Next, you need to look for the “DHCP server” setting option. I am using a TP-Link Archer C6 router, and it’s available under Advanced -> Network. For other routers, it may be present under a different page, so look it up and find the settings page.
-
Once you are here, enter the IP address of your Raspberry Pi in bothPrimary DNS and Secondary DNS. The IPv4 address you noted above in step #16 is the IP address of your Raspberry Pi. After that, click on “Save”. Now, this will redirect all the traffic to Pi-hole on Raspberry Pi to filter out all the ads and trackers. In the future, if you want to remove Pi-hole’s configuration from your router, simply delete both the DNS, and you will have your connection like before.
-
Next, scroll down and move to the “Address Reservation” section. For other routers, you will have to look for this option under different setting pages. We need toperform this step to prevent any IP conflict issue. Basically, you can reserve the IP address of the Raspberry Pi, so it’s not assigned to any other device in your home network.
-
Click on “Add” and enter the IP address of Raspberry Pi in the “Reserved IP Address” field. You can find theMAC addressof RPi from the client list mentioned below on the same page. Next, give a name in the “Description” field and turn on the “Enable This Entry” checkbox. Finally, click on “Save”. It will reserve the Raspberry Pi’s IP address.
-
If you areunable to find the MAC addressof your Raspberry Pi, open the Terminal on RPi and runifconfig. Under “wlan0”, check the value of “ether”. That’s the MAC address of your RPi.
-
Finally,restart your router, and the changes will be applied.
Block Ads & Trackers With Pi-hole on Raspberry Pi
-
You have set up Pi-hole and made all the changes necessary. Now, it’s time to see Pi-hole in action. Open the web interface address of Pi-hole, i.e.[IP address of RPi]/admin. You can open the page on any device in the home network.
-
Now, log in and you will find the Pi-hole dashboard with all the stats and queries that are being redirected to Raspberry Pi.
-
Scroll down, and you willfind the top permitted and blocked domains. Although it didn’t happen to me, but if you cannot access a website, open the Query log from the left menu and whitelist the related domain. You can alsoclick on a suspicious domain and choose to blacklist it.
-
At the bottom, you willfind all the deviceswith a list of total and blocked requests.
Disable System-wide Ads and Trackers With Pi-hole & Raspberry Pi on Your Home Network
So that is how you can set up Pi-hole on Raspberry Pi to block ads and trackers on your home network. The steps may seem complex, but it’s certainly doable, and you can get it working in just a few minutes. Anyway, that is all from us. If you are facing any issues, do comment down below and let us know. We will surely help you out.
Arjun Sha
Passionate about Windows, ChromeOS, Android, security and privacy issues. Have a penchant to solve everyday computing problems.
Add new comment
Name
Email ID
Δ