// Block ads at the source. Protect every device.
ADS ARE TRACKERS.
Every advertisement you see is a data collection device. Ad networks track your browsing across websites, build profiles of your interests, and sell your data to the highest bidder. Pi-hole blocks these trackers at the network level—before they ever reach your devices.
AD-BLOCKING IS SECURITY.
Malicious ads (malvertising) inject malware through legitimate websites. By blocking ads network-wide, you reduce your attack surface on every device in your home—smart TVs, phones, laptops, even IoT devices that can't run their own ad blockers.
TAKE BACK YOUR NETWORK.
Pi-hole puts you in control of your DNS. No more letting third parties decide what you see. No more tracking scripts loading on every page. Just a cleaner, faster, more private internet.
12 lessons. Complete Pi-hole control.
What is Pi-hole? How DNS-based blocking works. Installing Pi-hole.
BeginnerInstallation options, network configuration, first-time setup wizard.
BeginnerUpstream DNS providers, DNSSEC, DNS-over-HTTPS, DNS-over-TLS.
BeginnerUnderstanding blocklists. Adding, removing, and managing block sources.
IntermediateAllowing specific domains. Whitelist management and best practices.
IntermediateUsing Pi-hole as your DHCP server. Automatic DNS configuration.
IntermediateUsing the query log. Identifying blocked domains and trends.
IntermediateClient-specific filtering. Using groups for different devices.
AdvancedUsing the API. Custom integrations and automation.
AdvancedDNS caching, query optimization, and performance monitoring.
AdvancedMultiple Pi-holes, load balancing, and failover configuration.
AdvancedRegex blocking, local records, and custom configurations.
AdvancedPi-hole is a network-wide ad blocker that runs as a DNS sinkhole. Instead of blocking ads in each browser or app, you configure your network to use Pi-hole as your DNS server. Every DNS query from every device on your network passes through Pi-hole—and Pi-hole decides whether to resolve it or block it.
When you visit a website, your computer needs to translate the domain name (example.com) into an IP address. This is called a DNS query.
The ad server never gets queried, the ad never loads, and you save bandwidth.
# Run installation script curl -sSL https://install.pi-hole.net | bash
# Run Pi-hole in Docker
docker run -d \
--name pihole \
-e TZ=America/New_York \
-e WEBPASSWORD=yourpassword \
-p 53:53/tcp \
-p 53:53/udp \
-p 80:80 \
-p 443:443 \
-v pihole-data:/etc/pihole \
-v pihole-dnsmasq:/etc/dnsmasq.d \
--dns=127.0.0.1 \
--restart=unless-stopped \
pihole/pihole:latest
# On Debian/Ubuntu sudo apt update sudo apt install -y git curl wget dnsmasq # Clone and install git clone --depth 1 https://github.com/pi-hole/pi-hole.git /tmp/pihole cd /tmp/pihole/automated%20install/ sudo bash basic-install.sh
After installation, the setup wizard guides you through configuration:
# Access via hostname http://pi.hole/admin/ http://pihole.local/admin/ # Or via IP http://192.168.1.100/admin/
Login with the password you set during installation.
# View Pi-hole status pihole status # Enable/Disable blocking pihole enable pihole disable # Temporarily disable (5 minutes) pihole disable 5m # Update Pi-hole pihole -up # View version pihole -v
To use Pi-hole network-wide, change your router's DHCP settings:
Pi-hole forwards allowed queries to upstream DNS servers. Choose privacy-respecting providers:
| Provider | Primary | Secondary |
|---|---|---|
| Cloudflare | 1.1.1.1 | 1.0.0.1 |
| 8.8.8.8 | 8.8.4.4 | |
| Quad9 | 9.9.9.9 | 149.112.112.112 |
| AdGuard | 94.140.14.14 | 94.140.15.15 |
Encrypt DNS queries to prevent snooping:
# Configure DoH in web interface: # Settings > DNS > Upstream DNS Servers # Check: "Use HTTPS" # Cloudflare https://cloudflare-dns.com/dns-query # Google https://dns.google/dns-query # Quad9 https://dns.quad9.net/dns-query
# Configure DoT in web interface # Settings > DNS > Upstream DNS Servers # Cloudflare tls://cloudflare-dns.com # Google tls://dns.google # Quad9 tls://dns.quad9.net
Enable DNSSEC to verify DNS responses are authentic:
# In web interface: # Settings > DNS > DNSSEC # Check "Use DNSSEC"
Pi-hole will validate DNSSEC signatures before returning results.
Blocklists are lists of domain names that Pi-hole will block. They can include:
Pi-hole comes with several pre-configured blocklists. View them in:
# Web interface: Group Management > Blocklists # Or directly in /etc/pihole/*.list
Default lists include StevenBlack's list, MalwareDomains, and others.
# Popular blocklist sources: # StevenBlack Hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts # Firebog https://v.firebog.net/hosts/AdguardDNS.txt https://v.firebog.net/hosts/Easyprivacy.txt https://v.firebog.net/hosts/Prigent-Crypto.txt https://v.firebog.net/hosts/Prigent-Malware.txt # oisd https://oisd.nl/basicdomains https://oisd.nl/mtmalwaredomains
After adding blocklists, update Pi-hole's database:
# Via web interface: # Tools > Update Gravity > "Update" # Via command line: pihole -g
Sometimes legitimate domains get blocked. You need to whitelist them to restore functionality.
# Via web interface: # Whitelist > Add domain # Via command line: pihole whitelist doubleclick.net
Wildcards are supported:
# Block all subdomains of doubleclick.net *.doubleclick.net
# Add regex in Whitelist section # Regular expression: ^([a-z0-9]+\.)?example\.com$ # This matches: # example.com # www.example.com # anything.example.com
Pi-hole can serve as your network's DHCP server, automatically assigning IP addresses and telling devices to use Pi-hole for DNS.
Assign fixed IPs to specific devices:
# Find MAC address of a device # Tools > Network > Recent Devices # Or check your router's device list
The query log shows every DNS query Pi-hole processes:
# Access via web interface: # Query Log # Via command line: pihole -t
Each entry shows:
# Via command line: pihole -t -d 100 # Shows top 100 queries pihole -q domain.com
View historical data in:
Apply different rules to different devices:
Use cases:
# Via web interface: # Groups > Add new group # Example groups: # - "Kids" (strict blocking) # - "Work" (allow work domains) # - "Guests" (minimal blocking)
Assign blocklists and whitelists to specific groups:
Pi-hole has a comprehensive API for automation:
# Get auth token from web interface: # Settings > API > Show API token # Base URL http://pi.hole/admin/api.php
# Get summary statistics curl -s "http://pi.hole/admin/api.php?summary" | jq . # Get top domains curl -s "http://pi.hole/admin/api.php?topDomains" | jq . # Get query log (limited) curl -s "http://pi.hole/admin/api.php?getAllQueries" | jq . # Enable/Disable curl -s "http://pi.hole/admin/api.php?enable&auth=YOUR_TOKEN" curl -s "http://pi.hole/admin/api.php?disable&auth=YOUR_TOKEN"
# Add to whitelist via API curl -s "http://pi.hole/admin/api.php?list=white&add=example.com&auth=YOUR_TOKEN" # Add to blacklist via API curl -s "http://pi.hole/admin/api.php?list=black&add=ads.example.com&auth=YOUR_TOKEN"
Pi-hole caches DNS responses to speed up repeated queries:
# Cache size (default: 10000) # Edit /etc/dnsmasq.d/01-pihole.conf cache-size=10000
Pi-hole FTL (Faster-Than-Light) is the database engine:
# Check FTL status sudo systemctl status pihole-FTL # Restart FTL sudo systemctl restart pihole-FTL # Check database size ls -lh /etc/pihole/pihole-FTL.db
Run multiple Pi-holes for redundancy:
If one goes down, devices automatically use the other.
# Option 1: Use same blocklists # Configure both Pi-holes with identical blocklists # Option 2: Sync script # Create script that updates both via API # Option 3: Shared database # (Advanced - not officially supported)
Pi-hole doesn't natively load-balance, but your router can distribute DNS queries:
# Router DNS settings: # Primary DNS: 192.168.1.10 (Pi-hole 1) # Secondary DNS: 192.168.1.11 (Pi-hole 2) # Most devices will use primary # Fallback to secondary if primary unreachable
Block domains using patterns:
# In Local DNS > Domain Blocking > Regex # Block all tracking subdomains: .*\.analytics\..* # Block all ads from a domain: ^ads?\..+ # Common regex patterns: .*\.doubleclick\..* # Any subdomain of doubleclick .*-tracker\..* # Any domain ending with -tracker .*\.googlesyndication\..*
Override DNS for local domains:
# Examples: # homerouter.local > 192.168.1.1 # nas.local > 192.168.1.50 # myserver.local > 192.168.1.100
Block domains that use CNAME redirects:
# Add to /etc/pihole/custom.list 0.0.0.0 ad.doubleclick.net 0.0.0.0 pagead2.googlesyndication.com 0.0.0.0 googleadservices.com
You've completed the Pi-hole mastery guide. You now know how to:
Remember: