Skip to main content
← Back to Blog

How to Set Up Pi-hole on Raspberry Pi: Step-by-Step Guide

Install Pi-hole on Raspberry Pi and route DNS through it for network-wide ad and tracker blocking.

How to Set Up Pi-hole on Raspberry Pi: Step-by-Step Guide

How to Set Up Pi-hole on Raspberry Pi: Step-by-Step Guide

Set up Pi-hole on a Raspberry Pi to block ads and trackers across your entire network.

What is Pi-hole?

Pi-hole is a network-wide DNS sinkhole that protects your devices from unwanted content by filtering at the network level. Instead of installing ad blockers on every device, Pi-hole acts as your network’s DNS server and blocks malicious requests before they reach your devices.

Benefits:

  • Blocks ads and trackers across all devices on your network
  • Lightweight and runs on Raspberry Pi
  • Improves network performance and page load times
  • Reduces data usage
  • Free and open-source

Hardware Requirements

  • Raspberry Pi (any model with Ethernet recommended)
  • Micro SD card (8GB minimum, 32GB recommended)
  • Power supply for Raspberry Pi
  • Ethernet cable or Wi-Fi adapter
  • Another computer to configure initial setup

Step 1: Prepare Your Raspberry Pi

Install Raspberry Pi OS

  1. Download Raspberry Pi Imager
  2. Insert SD card into your computer
  3. Open Raspberry Pi Imager and select:
    • Raspberry Pi OS Lite (headless version)
    • Your SD card as destination
  4. Before writing, open the Imager OS customization options and:
    • Set a hostname (for example, raspberrypi)
    • Create a username and password
    • Enable SSH
  5. Click Write and wait for completion

Initial Setup

  1. Insert SD card into Raspberry Pi
  2. Connect Ethernet cable
  3. Power on the device
  4. Wait 2-3 minutes for first boot

Find Pi’s IP Address

On another computer on the same network, use Angry IP Scanner or run:

ping raspberrypi.local

Or check your router’s connected devices list.

Step 2: SSH Into Raspberry Pi

Open a terminal and connect:

ssh [email protected]

If .local does not resolve on your network, use the Pi’s IP address:

ssh [email protected]

Step 3: Install Pi-hole

Run the official installer:

curl -sSL https://install.pi-hole.net | bash

The installer will:

  • Ask about upstream DNS providers
  • Ask you to confirm networking details (including the Pi’s local IP)
  • Configure your system
  • Display your admin password at the end

Save your admin password!

Step 4: Access Pi-hole Dashboard

Open a web browser and navigate to:

http://raspberrypi.local/admin

Or use the IP address:

http://192.168.1.X/admin

Log in with your admin password.

Step 5: Configure Your Router’s DNS

For network-wide protection, point all devices to Pi-hole:

  1. Log into your router (typically 192.168.1.1)
  2. Find DHCP settings or DNS settings
  3. Set DNS to Pi-hole’s IP address (e.g., 192.168.1.100)
  4. Save and reboot router

All connected devices will now use Pi-hole as their DNS resolver.

Step 6: Add Blocklists

Pi-hole works by blocking known ad and tracking domains. Add blocklists:

  1. Go to Adlists in the dashboard
  2. Add popular blocklists such as:
    • https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
    • https://adaway.org/hosts.txt
  3. Update gravity from the dashboard, or run:
pihole -g

Step 7: Monitor and Manage

Dashboard Overview

  • Queries today: Total DNS queries
  • Blocked: Ads and trackers blocked
  • Clients: Devices on your network
  • Gravity: Active blocklists

Configure Whitelisting/Blacklisting

  • Whitelist: Domains to always allow
  • Blacklist: Domains to always block
  • Regex: Advanced filtering with regular expressions

Maintenance

Keep Pi-hole Updated

pihole -up

Monitor System Resources

Use SSH to check system health:

top

Watch disk space and memory usage.

Backup Your Configuration

Use Pi-hole’s built-in backup/export from the web dashboard (Settings/Teleporter in current releases). For a file-level backup, copy the Pi-hole config directory:

sudo cp -r /etc/pihole /path/to/backup/pihole-config

Troubleshooting

Devices Not Using Pi-hole

Check:

  1. Router DHCP settings pointing to Pi-hole
  2. Device DNS settings (may override router settings)
  3. Devices may need reboot after router config change

Pi-hole Not Blocking Ads

  • Update blocklists manually in dashboard
  • Check gravity has been updated
  • Verify devices are actually using Pi-hole as DNS

Pi-hole Slow or Unresponsive

  • Reduce number of blocklists
  • Monitor system resources via SSH
  • Consider updating Raspberry Pi OS

Final Thoughts

Pi-hole is a fantastic tool for network-wide ad blocking and tracking prevention. Once set up, it requires minimal maintenance and provides immediate benefits across all your devices. The investment in a Raspberry Pi pays off quickly in improved browsing experience and network performance.

Enjoy an ad-free internet!