Setting Up Pi-hole Ad Blocker on Raspberry Pi
Online advertising is ubiquitous. Websites, mobile apps, smart TVs and even some smart home devices keep loading ads and tracking scripts. Browser ad blockers help for individual devices, but don’t protect every device in a network.
This is where Pi-hole comes in, working as an ad blocker for all of your network. Rather than blocking ads after they have been loaded, Pi-hole blocks many advertising and tracking domains from being contacted in the first place. The result is less advertising, better privacy, less bandwidth use and often faster browsing.
Raspberry Pi is one of the best platforms to run Pi-hole on. The Raspberry Pi uses very little power, is always on, and is powerful enough to provide DNS filtering for an entire home network.
The guide takes you through everything from installing and configuring through to optimising, troubleshooting and advanced features.
What Is Pi-hole?
Pi-hole is a DNS-based ad blocker.
Instead of installing ad-blocking software on every device, Pi-hole sits between your devices and the internet.
When a device requests a website:
- The device asks a DNS server for an IP address.
- Pi-hole checks the request.
- If the domain belongs to an advertising or tracking service, Pi-hole blocks it.
- If the domain is legitimate, Pi-hole forwards the request to an upstream DNS provider.
This process happens automatically and transparently.
How Pi-hole Works
Normally, DNS requests follow this path:
Device → Router → DNS Server → Internet
With Pi-hole installed:
Device → Pi-hole → DNS Server → Internet
Pi-hole examines every DNS request.
If a request matches a blocked domain:
ads.example.com
tracking.example.com
analytics.example.com
Pi-hole returns a non-routable address instead of the real IP.
The ad never loads.
Why Use Pi-hole?
Pi-hole offers several advantages over browser-based ad blockers.
Network-Wide Protection
Every device benefits automatically:
- PCs
- Laptops
- Smartphones
- Tablets
- Smart TVs
- Streaming boxes
- Game consoles
- Smart home devices
Improved Privacy
Many websites contain dozens of tracking domains.
Pi-hole prevents many of these requests from ever reaching advertisers.
This reduces online tracking and profiling.
Reduced Bandwidth Usage
Blocked content never downloads.
This can reduce:
- Mobile device bandwidth
- Smart TV traffic
- Background analytics traffic
Faster Browsing
Pages often load more quickly because advertising servers are never contacted.
Fewer DNS lookups also reduce delays.
Detailed Analytics
Pi-hole provides visibility into:
- Most requested domains
- Top clients
- Blocked requests
- DNS performance
- Network activity trends
Hardware Requirements
Pi-hole has modest requirements.
Suitable Raspberry Pi models include:
| Model | Recommended | | | — | | Raspberry Pi 5 | Excellent | | Raspberry Pi 4 | Excellent | | Raspberry Pi 3B+ | Excellent | | Raspberry Pi Zero 2 W | Good | | Raspberry Pi Zero W | Usable |
Even older Raspberry Pi models can handle DNS filtering for a typical household.
Recommended Setup
For best results:
| Component | Recommendation | | | — | | Raspberry Pi | Pi 3B+ or newer | | Storage | Quality microSD card | | Network | Ethernet preferred | | Power | Official PSU | | OS | Raspberry Pi OS Lite |
Using Ethernet ensures maximum reliability.
Installing Raspberry Pi OS
Install Raspberry Pi OS Lite using Raspberry Pi Imager.
Recommended settings:
- Enable SSH
- Configure hostname
- Set username
- Configure Wi-Fi if needed
After booting:
sudo apt update
sudo apt full-upgrade -y
Reboot:
sudo reboot
Assigning a Static IP Address
Pi-hole should always have the same IP address.
Without a static address, DNS clients may lose connectivity after reboots.
Check current address:
hostname -I
Example:
192.168.1.100
The preferred approach is creating a DHCP reservation on your router.
This guarantees the Raspberry Pi always receives the same IP address.
Installing Pi-hole
Pi-hole provides an automated installer.
Download and start installation:
curl -sSL https://install.pi-hole.net | bash
The installer launches a guided setup process.
Installation Wizard Options
During installation you will select:
Network Interface
Choose:
eth0
for Ethernet or:
wlan0
for Wi-Fi.
Ethernet is recommended.
Upstream DNS Provider
Common choices include:
- Google DNS
- Cloudflare DNS
- Quad9
- OpenDNS
Many users choose:
Cloudflare
1.1.1.1
for speed and privacy.
Block Lists
Accept the default list initially.
Additional lists can be added later.
Admin Interface
Enable:
Web Interface
This provides the management dashboard.
Logging
Enable query logging.
Logs help troubleshoot DNS issues and identify blocked domains.
Accessing the Pi-hole Dashboard
Once installation completes:
http://192.168.1.100/admin
Replace the IP with your Pi-hole address.
The dashboard displays:
- Total queries
- Queries blocked
- Top domains
- Top clients
- Recent activity
Setting the Pi-hole Password
Set or change the dashboard password:
pihole -a -p
Enter the desired password.
Configuring Devices to Use Pi-hole
Pi-hole only works when devices use it as their DNS server.
There are two common methods.
Method 1: Configure Router DNS (Recommended)
Change router DNS settings:
Primary DNS:
192.168.1.100
All connected devices automatically use Pi-hole.
Benefits:
- One-time setup
- Covers all devices
- Simpler management
Method 2: Configure Individual Devices
Set DNS manually.
Windows:
IPv4 Settings
Preferred DNS:
192.168.1.100
Linux:
DNS:
192.168.1.100
Android and iPhone settings are similar.
Testing Pi-hole
Check DNS functionality:
nslookup google.com
You should see Pi-hole responding.
Visit the dashboard and verify queries appear.
Blocked domains should increment over time.
Understanding the Dashboard
The dashboard provides valuable statistics.
Total Queries
Number of DNS requests processed.
Queries Blocked
Requests blocked by filtering rules.
Percentage Blocked
Shows effectiveness of configured lists.
Top Clients
Devices generating DNS traffic.
Top Blocked Domains
Frequently blocked advertisers and trackers.
Managing Block Lists
Block lists determine what gets filtered.
Update lists:
pihole -g
This downloads and processes the latest domains.
Adding Custom Block Lists
Navigate to:
Group Management
→ Adlists
Additional lists can target:
- Advertising
- Malware
- Telemetry
- Tracking
- Scam domains
Choose reputable lists to avoid overblocking.
Whitelisting Domains
Occasionally a legitimate service may break.
Examples:
- Embedded videos
- Login systems
- Mobile apps
Whitelist a domain:
pihole -w example.com
Or use the web interface.
Blacklisting Domains
Block specific domains manually:
pihole -b annoyingdomain.com
Useful when unwanted content bypasses existing lists.
Updating Pi-hole
Regular updates improve security and functionality.
Update:
pihole -up
This updates:
- Core software
- Web interface
- DNS engine
Viewing Real-Time DNS Activity
Pi-hole can display live traffic.
Use:
pihole -t
This shows:
- Client IPs
- Requested domains
- Allowed requests
- Blocked requests
It is one of the most useful troubleshooting tools.
Using Pi-hole with Unbound
By default, Pi-hole forwards requests to external DNS providers.
For greater privacy, install Unbound.
Benefits include:
- Recursive DNS resolution
- No third-party DNS provider
- Improved privacy
- Greater control
The lookup process becomes:
Device
→ Pi-hole
→ Unbound
→ Root DNS Servers
This creates a fully self-hosted DNS solution.
Running Pi-hole on Raspberry Pi Zero
Many users dedicate a Pi Zero 2 W exclusively to Pi-hole.
Advantages:
- Very low power consumption
- Silent operation
- Small footprint
- Inexpensive hardware
A Pi Zero 2 W can comfortably handle thousands of DNS requests daily.
Common Problems and Solutions
Devices Not Using Pi-hole
Check DNS settings.
Verify clients are using:
192.168.1.100
as DNS.
Dashboard Not Accessible
Restart services:
sudo systemctl restart pihole-FTL
or:
sudo reboot
Ads Still Appear
Some ads originate from the same domain as website content.
These are harder to block using DNS alone.
Pi-hole is highly effective but cannot eliminate every advertisement.
Slow DNS Responses
Test upstream DNS servers.
Cloudflare, Quad9, and Google often provide better performance than ISP DNS servers.
DNS Resolution Fails
Verify service status:
sudo systemctl status pihole-FTL
Restart if necessary:
sudo systemctl restart pihole-FTL
Security Best Practices
Although Pi-hole is relatively safe, basic precautions are important.
Keep Raspberry Pi Updated
sudo apt update
sudo apt full-upgrade
Use Strong Passwords
Protect the dashboard with a secure password.
Restrict Remote Access
Avoid exposing the admin dashboard directly to the internet.
Use VPN access if remote management is required.
Backup Configuration
Pi-hole settings can be exported through the dashboard.
Backups simplify recovery after hardware failure.
Resource Usage
Pi-hole is extremely lightweight.
Typical Raspberry Pi resource consumption:
| Resource | Usage |
|---|---|
| CPU | Usually under 5% |
| RAM | 100–300 MB |
| Storage | Less than 1 GB |
| Power | A few watts |
Even a small Raspberry Pi can run continuously for years.
Advanced Pi-hole Features
Experienced users often expand Pi-hole with:
Recursive DNS
Using Unbound.
Local DNS Records
Assign custom hostnames to local devices.
Conditional Forwarding
Resolve local network names.
DHCP Server
Allow Pi-hole to replace router DHCP functionality.
Multiple Pi-hole Servers
Create DNS redundancy.
DNS-over-HTTPS
Encrypt DNS traffic.
DNS-over-TLS
Improve privacy and security.
These features can transform Pi-hole into a sophisticated network management platform.
Final Thoughts
Pi-hole is one of the most useful Raspberry Pi projects for privacy, helping to cut down on online tracking and block ads across your entire network. Pi-hole protects every compatible device automatically, and provides detailed insight into DNS activity, unlike browser-based ad blockers.
Easy to install, minimal resource requirements, and easy to maintain. If you want to make surfing faster, remove unwanted tracking, see more of the network, or just have a cleaner internet experience, Pi-hole is still one of the most practical and rewarding applications for a Raspberry Pi.
