Pihole is a DNS sinkhole which provides the ability to block content Network wide without any need for client software.

What that essentially means is that we can use a Pihole Install to filter any unwanted content (In our case Ads) for all out network clients without any client-side configuration, This is especially usefull for mobile devices.

Note: Pihole CANNOT block Youtube Ads, A Browser extension like uBlock Origin might help better there.

Prerequisites

  • A Raspberry-PI 3 or UP
  • A SD Card
  • Access to your DHCP Server (Usually inbuilt in your router) to change DNS Server address
  • Some free time

Prepare Pi for install

Download base OS image

First we will need to install a base OS for our Pi, we will be using The Raspberry Pi OS for this.

Download the image somewhere on your computer, you can choose any image but the LITE is recommended for headless operations.

Write image to SD Card

First we will need to unzip the downloded file and get the Image file we will write to the sd card.

In my case it’s 2021-05-07-raspios-buster-armhf-lite.img

Note: DO NOT Write the ZIP File directly to the SD card.

Use GUI on Linux/Windows

Pihole provides a nice GUI tool to write images to SD cards called rpi-imager.

Download the rpi-imager tool for your platform

  • Windows

Download the Official Tool from here and install it.

  • Linux

Install the rpi-imager from your Distro repos

The command will be diffrent depending on your Distro

On Debian based Distros like Ubuntu simply run

sudo apt update && sudo apt-install rpi-imager

Use dd on Linux

Simply dd the Downloaded image to the sdcard using

sudo dd if=<Path to Image File> of=<PAth to SD card> bs=4096 status=progress && sync

Example

sudo dd if=./2021-05-07-raspios-buster-armhf-lite.img of=/dev/sdb bs=4096 status=progress && sync

Boot and Update Raspberry-Pi

Insert our newly created sd card in the Pi and boot it up with the network cable plugged in and wait for the initial resize and stuff to finish

A Monitor and keyboard is needed to be atatched if you can’t SSH Into the Pi for configuration and initial setup.

The first boot might take some time.

Login once done the default username is pi and the password is raspberry

Update the system with

sudo apt-get update && sudo apt-get dist-upgrade

Reboot the Pi to make sure all our updates are applied

Install Pi-hole

The Pi-hole Project provides a nice handy script to get us started

Simply Run

curl -sSL https://install.pi-hole.net | bash

Note the WEB GUI Password it generates, We will need that to further configure Pi-hole and monitor status

Configure Pi-hole

After all this is done your Pi-hole install should be up and running and now we can configure it

The Pi-hole Project provides a nice WEB GUI to monitor the status aswell as to configure it, It’s available at port 80 under /admin

Get the ip address of Pi using ip addr

Example http://172.17.1.252/admin

Use the Password we got from the Install Script to login.

Usually the default ad blocking lists included in the Pi-hole are tried and tested and will block 90% of the Ads, You can lave it as it is for now.

Change any settings in the GUI you want (the Defaults are fine too).

Reboot the Pi one last time.

Configure the DHCP Server

Although Pi-hole Procides a handy DHCP Server too i usually prefer using my Router’s inbuilt one which you most probably are too.

Configure your DHCP Server (Usually in your Router’s GUI Page) and the change the DNS Server to your Raspberry Pi’s IP Address

Refer to Your Router’s manual page as this step is highly device specific.

Note: Add the Pi’s IP as the Primary DNS Server

You might’ve noticed that there are usually multiple fields for DNS, It’s recommened by the project to leave all the other fields blank and have Pi-hole as your only DNS Provider however if you do this your network will be unusable if your Pi goes down.

We can add a secondry DNS Provider to combat this which will act as a fail over for when the Pi goes down however with this approach some Ads might be able to slip through (Rare).

Some of the Popular secondry DNS Privders you can use are

  • Google 8.8.8.8 , 8.8.4.4.
  • Cloudflare 1.1.1.1 , 1.0.0.1
  • OpenDNS 208.67.222.222 , 208.67.220.220

Let me know if i missed anything.