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

  1. Download and install the latest version of Raspberry Pi OS from the official website.
  2. Download, install, and run the Raspberry Pi Imager
  3. Choose the OS and microSD card storage, and configure the settings to enable SSH and a user.
  4. Install the OS onto the microSD card and insert it into the Raspberry Pi.
  5. Plug in the Ethernet dongle and Ethernet cable into the Raspberry Pi if it doesn't have built-in WiFi.
  6. Power up the Raspberry Pi.

Step 2: Connect to the Raspberry Pi via SSH

  1. Find the IP address assigned to the Raspberry Pi from your router.
  2. Open a terminal and type ssh pi@<ip_address> (replace <ip_address> with the IP address of your Raspberry Pi).
  3. Enter your username and password.

Step 3: Install Pi-hole

  1. Update your Raspberry Pi by running sudo apt-get update && sudo apt-get upgrade.
  2. Install Pi-Hole by running curl -sSL https://install.pi-hole.net | bash Source.
  3. Follow the on-screen instructions to complete the installation.
  4. Save the URL to the admin panel presented at the end of the installation process.

Step 4: Configure your router

  1. Log in to your router's web interface.
  2. Find the DNS settings and change the primary DNS server to the IP address of your Raspberry Pi.

Step 5: Test Pi Hole

  1. Visit https://cnn.com.
  2. If you don't see ads, the setup is successful.
  3. 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:

  1. Run the command sudo dpkg-reconfigure locales to generate locales.
  2. Press "continue" unless you need to add more locales. Source