How to Set Up Pi-hole on Raspberry Pi to Block Ads and Trackers – Guide

While online advertising is a major source of income for many of their favorite websites, some people want to avoid it for a variety of reasons, including performance and privacy concerns. You can install ad blocking software on each of your devices or use other more efficient methods like pi-hole. Pi-hole is a universal network-wide ad blocker that can be installed on a Linux-based device to set up a server that filters all web traffic at the local network level and blocks ads on any device connected to yours home network. It protects your ad network and trackers without requiring individual device configurations. Pi-hole can block ads on any network device (e.g. smart appliances) and, unlike browser add-ons, can block ads on any software. In this Raspberry Pi Zero tutorial series,we will guide you through the configuration up a Pi-Hole on a Raspberry Pi Zero W. But before we continue, let’s understand what the Pi-Hole is and how it blocks ads. ..

Pi-hole is a Raspberry Pi-based network-wide advertising filter that can be easily installed on Raspberry Pi Zero by running some installation commands on a Raspberry Pi running Raspberry Pi OS. Once installed, you can configure your devices to use their IP addresses so that all traffic on those devices is routed through Pi-Hole. That way, when a website (which serves ads) requests that its ad server’s domain fetch an ad, Pi-hole checks your domain name against the blacklisted ad service record. ..

Install Pi-hole on Raspberry Pi

sudo apt-get install pi-hole

If you are using Putty or VNC to 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 console.

Once the initial steps are complete, Pi-hole will take you through the setup screen. Press “Enter” to display information about the Pi hole. Remember that you can only navigate the UI via the keyboard. Use the arrow keys and “Tab” to cycle through the options. And press the “Spacebar” if you want to select an option.

After a few dialogs, it will ask you to provide a static IP address. Enter it again. ..

If the Raspberry Pi is connected via Wi-Fi, use “wlan0”. If using a wired Ethernet connection, use “eth0”.

Then it will ask you to choose a DNS provider. I usually use Google DNS server, but you are free to choose your own. ..

Previously, there were multiple third-party host files, but now Pi-hole uses a unified list of host files to reduce incompatibility. This makes it easier to use and keep your computer running smoothly.

After that, you can choose between IPv4 and IPv6 protocols. If you press the spacebar, both options will be checked. ..

After you have set a static IP address for your Raspberry Pi, you will need to connect to it using a computer. To do this, open a web browser on your computer and enter the IP address that you set for your Raspberry Pi. ..

Configure your router

To access your router’s settings, type 192.168.0.1 into a web browser on any device in your home network and hit enter. Next, enter your router’s default credentials and login. ..

Next, you need to look for the DHCP server configuration option. I’m using a TP-Link Archer C6 router and it’s available under Advanced -> Network. For other routers, it may be present on a different page, so look for up and find the settings page.

Once you have your Raspberry Pi’s IP address, enter it in both the primary DNS and the secondary DNS. The IPv4 address you noted above is the IP address of your Raspberry Pi. After that, click on “Save.” Now this will redirect all traffic to Pi-hole on Raspberry Pi to filter out all ads and trackers. In the future, if you want to remove the Pi-hole configuration from your router, just delete both DNS and you will have your connection as before.

To avoid any IP conflict issue, you can reserve the Raspberry Pi’s IP address in the Address Reservation section. ..

The Raspberry Pi IP address can be reserved by entering it in the “Reserved IP Address” field on the Raspberry Pi website. You can find the MAC address of the RPi in the client list mentioned below on the same page. Then give a name in the “Description” field and activate the “Enable this entry” checkbox. Finally, click on “Save”.

If you can’t find your Raspberry Pi’s MAC address, open Terminal on the RPi and run ifconfig. In “wlan0” check the value of “ether.” This is the MAC address of your RPi. ..

Restart the router and the changes will take effect.

Final note

How to Set Up Pi-hole on Raspberry Pi to Block Ads and Trackers In order to protect your computer from being tracked and ads, you will need to set up Pi-hole. This guide will show you how to do so on a Raspberry Pi.

  1. Choose the rightPi-hole server: You should choose a Pi-hole server that is compatible with your operating system and your network. For example, if you are using Ubuntu 18.04 LTS, then the pi-hole server should be Ubuntu 18.04 LTS compatible. If you are using Debian 8 or 9, then the pi-hole server should be Debian 8 or 9 compatible. If you are using Fedora 24 or 25, then the pi-hole server should be Fedora 24 or 25 compatible. 2 ConfigurePi-hole: After choosing a compatible Pi-hole server, configure it according to your needs by following these steps: 1) In terminal, type sudo nano /etc/pi-holes/config 2) Type the following content into nano and press enter: 3) Add the following line at the bottom of nano: 4) Type in this line into nano again and press enter: 5) Save and close nano 6) Type in this command into terminal: 7) Type sudo service pi-holes start 8) Press enter