Learn how to block ads and trackers on your network with this easy-to-follow guide!

Discover how to install Pi-hole on a Raspberry Pi to take control of your internet usage and protect your devices from unwanted advertisements and tracking. Follow our step-by-step guide to setup the …


Updated September 18, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


Discover how to install Pi-hole on a Raspberry Pi to take control of your internet usage and protect your devices from unwanted advertisements and tracking. Follow our step-by-step guide to setup the popular DNS sinkhole tool on your Raspberry Pi.

Pi-hole is an open source tool that allows you to block ads, trackers, and other unwanted content on your local network. It functions as a DNS sinkhole by intercepting and filtering out known advertisements and malicious websites before they reach your devices. By running Pi-hole on a Raspberry Pi, you can ensure that all devices connected to your network benefit from the ad blocking capabilities. This article will walk you through the process of installing Pi-hole on a Raspberry Pi step-by-step.

Preparing Your Raspberry Pi:

  1. Download the latest version of Raspbian Lite from the official Raspberry Pi website and flash it to your SD card using Etcher or another tool.
  2. Enable SSH by creating an empty file named “ssh” on the boot partition of the SD card. This will allow you to access the Pi remotely without a monitor, keyboard, or mouse.
  3. Connect your Raspberry Pi to power and connect it to your network via Ethernet cable.
  4. Find your Pi’s IP address by checking your router’s DHCP client list or using a tool like Angry IP Scanner.
  5. SSH into the Pi using the IP address, username “pi”, and password “raspberry”.
  6. Update the system and install necessary packages:
sudo apt update && sudo apt upgrade
sudo apt install -y vim git
  1. Reboot your Pi:
sudo reboot now

Installing Docker and Pi-hole:

  1. Install Docker on your Raspberry Pi by running the following commands:
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker pi
  1. Log out of the Pi and log back in to apply the Docker group changes.
  2. Pull the latest version of Pi-hole from Docker Hub:
docker pull pihole/pihole:latest
  1. Create a directory for Pi-hole’s configuration files:
sudo mkdir -p /etc/pihole
  1. Run Pi-hole using Docker with the following command:
docker run -d \
  --name pihole \
  -p 53:53/tcp -p 53:53/udp \
  -p 80:80 \
  -p 443:443 \
  -e TZ="Your Timezone" \
  -e WEBPASSWORD="your_password" \
  --dns=127.0.0.1 --dns=1.1.1.1 \
  -v /etc/pihole:/etc/pihole \
  -v /var/run/docker.sock:/var/run/docker.sock \
  pihole/pihole:latest

Replace “Your Timezone” with your timezone (e.g., America/New_York) and choose a secure password for the web interface in “your_password”. This will start Pi-hole in the background and map its ports to your Raspberry Pi.

Configuring Your Devices:

  1. Set your router’s DNS server to the IP address of your Raspberry Pi. You can find this by running hostname -I on the Pi.
  2. Visit http://pi.hole/ in a web browser to access the Pi-hole admin interface and login with the password you set earlier.
  3. In the admin interface, click “Allowlist” to add any local devices that should be exempt from ad blocking (e.g., smart TVs or IoT devices).
  4. To block ads on all devices connected to your network, configure each device to use the Raspberry Pi as its DNS server. On most routers, this can be found under “LAN Settings” or “DHCP Server”.
  5. Enjoy an ad-free internet experience!

Troubleshooting: If you encounter any issues during the installation process, visit the official Pi-hole forums at https://discourse.pi-hole.net/. The community there is very helpful and can provide support if needed. Additionally, you can check the logs for Docker by running docker logs pihole to see what errors may be occurring.

In conclusion, installing Pi-hole on a Raspberry Pi provides a simple and effective way to block ads and trackers on your local network. By using the power of Docker, this process is straightforward and can be done in just a few minutes. Now you can protect all devices connected to your network from unwanted content while still having access to the web. Happy ad-blocking!