Configure Pi-hole on Raspberry Pi

Configure Pi-hole on Raspberry Pi

avatar

AAAS24

November 20, 2021

Technology

Project Description

This document describes the steps taken to make pihole function on a RaspberryPi.

Pi-Hole is an open source software used for network-wide ad blocker. This allows your devices that don’t have ad-blockers to be served with the pesty ads we all know too well. This software has been available for quite a bit but the cool thing is how easy it is to set up and how cheap you can do it yourself.

Hardware:

We acquire a Raspberry Pi 4 with accessories for about $100. However, you can choose a less expensive Raspberry model and memory card and decrease that cost many times. However, since I can’t compare performance on those devices, I leave you a breakdown and links in case you are interested on replicating this project in your own home.

Item Cost($)
Raspberry Pi 4 Model B - 4 GB RAM 55
Official Raspberry Pi Power Supply 5.1V 3A with USB C - 1.5 meter long 7.95
Official Raspberry Pi Foundation Raspberry Pi 4 Case - Red White 6
Micro-HDMI to HDMI Socket Adapter Cable 7
SanDisk 256GB Extreme microSDXC UHS-I Memory Card with Adapter 40

You will also need:

  • Internet cable
  • Network controller. For our case, we use Unifi

Please note that although this is teh software we chose, you could choose cheaper options as this project does not use all the memory card nor capacity available in the hardware.

Pi-hole Configuration

1.1) Installing an OS

Based on the steps described in https://pi-hole.net, you can use multiple OS. We decided to use the Ubuntu version for IoT that does not have a server to have a more stable and minimal software layer. This OS requires a ubuntu account as it only supports SSH

Go to Ubuntu Website and download raspberry Pi Ubuntu Server 64B.

Note: you could probably use the raspberry Pi Ubuntu Server 32B but I would definitely stir away from Raspberry Pi Core, because even through will likely be more stable, it also has bare functions and basic commands as "app get" or "curl" are not available. It is also recommended to have the raspberry pi unit physically connected to ethernet during this process. 

Through the installation process you will need to create an image. You can use the RaspberryPi Imager for Mac to flash your drive.

RaspberryPi Imager Application

Make sure you enable SSH by running the following commands:

Type sudo apt-get install openssh-server
Enable the ssh service by typing sudo systemctl enable ssh
Start the ssh service by typing sudo systemctl start ssh
Test it by login into the system using ssh user@server-name

Code source: Ubuntu Linux install OpenSSH server (Vivek Gite)

1.2) Configuring Static IP

We have a network management system in place, so we did it at the network controller level.

1.3) Installing pihole

Now that you have access to your rasberry Pi, go to Pihole Github and follow the instructions.

During the installation it requires to select a Upstream DNS Provider. We selected “Clodflare (DNSSEC)”. We favor this provider because it favors speed and privacy. You can read more about it here. For all other options during the configuration, we chose default values. These options included Web Interface (On), Web Server (On) and Logging (On) among others.

Once the installation is over, you will see a box like in the image below, where you are given IP addresses for your DNS server and the login information for the web console.

Post Pi-hole Installation

As the Pi-ole documentation states: “once the installer has been run, you will need to configure your router to have DHCP clients use Pi-hole as their DNS server which ensures that all devices connecting to your network will have content blocked without any further intervention.

If your router does not support setting the DNS server, you can use Pi-hole’s built-in DHCP server; be sure to disable DHCP on your router first (if it has that feature available).

As a last resort, you can manually set each device to use Pi-hole as their DNS server.” Here is a cool video on Youtube that walks through some examples at the end by manually updating the DNS server in a TV, iphone and PC.

Watch the video

In our case, we have Unifi Network Manager. For any other unifi users, you may find a step by step below. or other users, please feel free to skip to the Web Console section.

Post Pi-hole Installation for Unify users only

1) Step 1:

On your Network Unifi console, select “Networks” on the left side. Then click on the network row that will appear on the right side of the console.

2) Step 2:

Click “Advanced” options.

3) Step 3:

Look for the “DHCP Name Server” section. Select “Manual” from the drop down.

4) Step 4:

Type the IP-4 address provided by the pi-hole wizard.

5) Step 5:

Repeat the same for the v6 in the appropriate section. Save all changes.

Pi-hole Web Console

If you use the http link provided by the wizard, you can see the Pi-hole web server. I may dig deeper into what is available here once we have enough data flowing, but wanted to share what it partially looks like.

Web Console

Recent Blog Articles