How to Install Pi-hole on a Raspberry Pi

These instructions will explain how to install Pi-hole on a Raspberry Pi. 

Pi-hole is a DNS sinkhole and installing it on a Raspberry Pi is one of the best places to run it thanks to a handy script that walks you through the whole process. As with all scripts, make sure that you review it to ensure that you’re comfortable running it. There are many different systems that you can run Pi-hole on, and it’s always a good idea to have more than one DNS server (for redundancy purposes), so check out our other Pi-hole tutorials if you’re interested in running it on another device!

How to Install Pi-hole on a Raspberry Pi

Before we look at how to install Pi-hole on a Raspberry Pi, ensure that you can SSH into your Raspberry Pi with a valid Raspberry Pi operating system. If you aren’t sure how, please follow these instructions to install Raspbian (Raspberry Pi OS)

pi-hole raspberry pi main ssh screen

There are two main ways to install Pi-hole: an automated installer or by downloading the installer and running the application. I will include both sets of instructions, but we will be utilizing the automated installer in this tutorial.

1. The automated installer requires root privileges. Gain root access by typing this command:

sudo su

2. Run one of the two command(s) to install Pi-hole:

Method 1 (Automated Installer)

curl -sSL | bash

Method 2 (Download and Execute)

wget -O
sudo bash
how to install pi-hole on a raspberry pi - command that needs to be run

3. During the installation, Pi-hole will ask you to configure multiple different settings. The first step is to configure your upstream DNS provider. For this tutorial, I will use OpenDNS, but this step is entirely user specific and can be tailored to your wants/needs.

dns selection

4. Pi-hole will prompt you with four lists that you can subscribe to that will automatically block ads. Since ad blocking is Pi-hole’s main attraction, it is suggested that you subscribe to all the default lists. However, if you’d rather not use these lists, you can add or remove them after Pi-hole has been installed.

block list selection

5. The next step will ask you if you’d like to block ads on IPv4, IPv6, or both. Generally, you will always select IPv4 but IPv6 blocking is personal preference.

protocols to block

6. The following screen will show you what your static IP is currently set as. Your Raspberry Pie was either configured with a static IP address (if you did this prior to starting the tutorial) or was given a dynamic IP address from DHCP. At this step, you can set this address to be your static IP address. If you aren’t happy with the selection, press No. If you would like to use the IP address shown, press yes.

static ip confirmation

NOTE: There are no guarantees that your router will not try and hand out this IP address to a different device via DHCP. Generally, you should try and go with an IP address higher than X.X.X.100 as DHCP has a lower chance of handing this address out. A better option is to set a static IP address in your router’s configuration for your Raspberry Pi. Also, keep in mind that this will be the IP address you will use as your DNS server in future steps!

ip conflict information

7. You will now be asked to install the web admin portal. I highly recommend this as the web interface is incredibly user friendly, but you have the option of managing everything through the terminal if you’d like. 

web admin interface selection

8. You will then be asked to install the web portal – keep that on and proceed.

web server install

9. The next step will ask you if you’d like to log queries. It’s a good idea to keep them on for potential troubleshooting but this setting is personal preference.

query logging

10. After setting your log preferences, you can then determine the level of detail you’d like for your domain searches. This is the final step in the configuration process. After this is set, the application will install.

privacy mode for FTL

11. The Pi-hole application will now be installed. The final step is to change the default Pi-hole application password and configure the application. Run this command to change your password:

pihole -a -p [YOUR PASSWORD]

12. Rebooting is not necessary, but I normally reboot the Raspberry Pi and then connect to the admin page at http://pi.hole/admin or http://[IP_ADDRESS]/admin

pi-hole admin interface

13. Pi-hole is now successfully installed. It is now necessary for you to point your devices to this DNS server. The first way of doing this is by configuring each device to use your newly created Pi-hole DNS server.

The second option is to configure your router to use your Pi-hole DNS server by default, which is my preferred method. Configuring the system this way forces all devices to automatically use this DNS server, which means any device connected to your router will automatically be using Pi-hole!

dns server on router

14. After you configure your systems to use Pi-hole, you have a few different options: you can add new blacklists, whitelist specific sites, add local DNS records (new 5.0 feature), or many more.

Conclusion – How to Install Pi-hole on a Raspberry Pi

This tutorial explained how to install Pi-hole on a Raspberry Pi. The best reason to install Pi-hole is that an older or less powerful Pi is perfectly capable of handling the DNS load, so an old device can be repurposed for this reason.

Thank you for checking out the tutorial on how to install Pi-hole on a Raspberry Pi. If you have any questions on how to install Pi-hole on a Raspberry Pi, feel free to leave them in the comments!