Pi-hole: adblocker in Raspberry Pi
What is PiHole?
Pi Hole is a network-based adblocker. It protects your devices from undesired content, without installing any adblocking software. It is easy to install as well as an open-source software which makes it more popular.
Pi-Hole puts itself between your device and an upstream DNS server and blocks out any requests to known ad and tracking servers. Pi Hole can accept DNS queries but it relies on the upstream server for resolving the queries.
Before setting up your Pi Hole server lets have a look at the requirements.
- Raspberry Pi + SD card
- USB power cable
- Ethernet cable
Setting up Pi Hole server on your Raspberry Pi
PiHole supports many OS the list is given below:
Step 1: OS installation into the Raspberry Pi
If you have a fresh SD card then install the Raspbian into the Pi. To install it refer to the blog on installing OS.
Before installing Pi Hole software make sure that the device has a static IP. Freshly installed OS has a dynamic IP by default, to make it static you need to make some changes in the /etc/dhcpcd.conf file by using the command sudo nano /etc/dhcpcd.conf
When you write the command on the terminal an editor will appear where you can manually set the IP and save it according to the interface i.e eth0 or wlan0.
Step 3: Install and run the Pi Hole software
- Open the terminal
- Install the software by writing the command -
curl -sSL https://install.pi-hole.net | bash
This command downloads the Pi-hole installer script and executes it.
You’ll be asked for permissions as shown in the figures:
Select the upstream DNS from the following options -
Select the IP address as a static IP
You’ll be asked for the log queries and it is recommended to keep it ‘ON’
Select the privacy mode for FTL from the 5 options mentioned
The installer will now install the required packages.
Keep the IP and the password with you for the login purpose.
Now, the installation is complete.
Reboot the system by the command: sudo reboot
192.172.x.y is the IP address you have set for Pi-hole.
The Pi-hole server looks like-
Pi-hole not only creates a server in a particular device but can also become a DNS server of your router to have Pi-hole automatically used by all the clients on your network. For more information, you can visit the Pi-hole website https://pi-hole.net/.