Setup Pi-hole on Raspberry Pi (2023)
Pi-Hole is a DNS-based filtering tool that can block ads, tracking, and malicious sites on your entire network. It takes around 10-30 minutes to set up.
Important:
- Pi-hole is unfortunately not great at blocking YouTube video ads. For that you would have to use AdBlock or µOrigin extension on your browser.
Prerequisites
- Raspberry Pi compatible with Raspberry Pi OS
- Micro SD card
- Micro USB power supply
- MicroSD card to USB adapter for installing the OS
- Micro B to Ethernet dongle and Ethernet cable if your Pi doesn't have built-in WiFi
Instructions
Step 1: Install Raspberry Pi OS
- Download and install the latest version of Raspberry Pi OS from the official website.
- Download, install, and run the Raspberry Pi Imager
- Choose the OS and microSD card storage, and configure the settings to enable SSH and a user.
- Install the OS onto the microSD card and insert it into the Raspberry Pi.
- Plug in the Ethernet dongle and Ethernet cable into the Raspberry Pi if it doesn't have built-in WiFi.
- Power up the Raspberry Pi.
Step 2: Connect to the Raspberry Pi via SSH
- Find the IP address assigned to the Raspberry Pi from your router.
- Open a terminal and type
ssh pi@<ip_address>
(replace<ip_address>
with the IP address of your Raspberry Pi). - Enter your username and password.
Step 3: Install Pi-hole
- Update your Raspberry Pi by running
sudo apt-get update && sudo apt-get upgrade
. - Install Pi-Hole by running
curl -sSL https://install.pi-hole.net | bash
Source. - Follow the on-screen instructions to complete the installation.
- Save the URL to the admin panel presented at the end of the installation process.
Step 4: Configure your router
- Log in to your router's web interface.
- Find the DNS settings and change the primary DNS server to the IP address of your Raspberry Pi.
Step 5: Test Pi Hole
- Visit https://cnn.com.
- If you don't see ads, the setup is successful.
- If you still see ads, turn your WiFi off and on.
Congratulations! You've successfully set up Pi Hole on your Raspberry Pi.
Known Issues
"Can't set locale; make sure $LC_* and $LANG are correct!"
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "nb_NO.UTF-8",
LC_MONETARY = "nb_NO.UTF-8",
LC_ADDRESS = "nb_NO.UTF-8",
LC_TELEPHONE = "nb_NO.UTF-8",
LC_NAME = "nb_NO.UTF-8",
LC_MEASUREMENT = "nb_NO.UTF-8",
LC_IDENTIFICATION = "nb_NO.UTF-8",
LC_NUMERIC = "nb_NO.UTF-8",
LC_PAPER = "nb_NO.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
This warning won't break anything, but you can fix it by following these steps:
- Run the command
sudo dpkg-reconfigure locales
to generate locales. - Press "continue" unless you need to add more locales. Source