Pi-hole is a DNS server that blocks ads and trackers for every device at home: phones, TV, console or computers, without installing anything on them. This guide explains how to install it on a Raspberry Pi with the official method and how to make your network use it.
In short
- Pi-hole blocks at the DNS level: when a device asks for an ad domain, it gets an empty answer.
- It needs a static IP and the router handing out its IP as the DNS server.
- It installs with a single command and is managed from a web panel and the
piholecommand.
Based on the official Pi-hole documentation. If you want to understand DNS before starting, read how DNS works.
How Pi-hole works
Every time a web page loads an ad, your device first asks “what is the IP of ads.ejemplo.com?”. Pi-hole receives that question and:
- If the domain is on a blocklist, it answers with a null address and the ad is not downloaded.
- If it is not, it forwards the question to a public DNS (your choice) and returns the answer.

Strengths and limits:
| Blocks well | Does not block well |
|---|---|
| Ads in apps and Smart TVs | Ads served from the same domain as content (for example, YouTube) |
| Trackers and telemetry | Content already embedded in the page |
| Known malware domains | Devices using their own encrypted DNS |
Requirements
According to the official documentation:
| Requirement | Value |
|---|---|
| RAM | 512 MB |
| Free space | 2 GB (4 GB recommended) |
| System | Raspberry Pi OS, Debian, Ubuntu, Fedora, Alpine… |
| Network | Static IP (or DHCP reservation on the router) |
Any current Raspberry Pi works, including the Zero 2 W. Preferably wired by Ethernet.
Ports used
| Port | Use |
|---|---|
| 53 TCP/UDP | DNS (required, no other DNS server may run on the Pi) |
| 80 and 443 TCP | Web panel (if taken, use 8080 and 8443) |
| 67 UDP | DHCP, optional |
Step 1: give the Raspberry Pi a static IP
Pi-hole must not change address: if it does, the whole network loses DNS. You have two options:
- DHCP reservation on the router (recommended): bind the Pi’s MAC to an IP, for example
192.168.1.10. - Static IP on the Pi itself: explained in set a static IP on Raspberry Pi OS.
Step 2: install Pi-hole
Update the system and run the official installer:
sudo apt update && sudo apt full-upgrade -y
curl -sSL https://install.pi-hole.net | bash
The documentation itself admits that running a script with | bash is debatable because you do not read it first. Alternative: download it, review it and run it.
wget -O basic-install.sh https://install.pi-hole.net
less basic-install.sh
sudo bash basic-install.sh
The wizard asks:
- Network interface (normally
eth0). - Upstream DNS: the server it forwards unblocked requests to, for example Cloudflare or Quad9.
- Blocklists: accept the default list.
- Web panel and query logging: leave it on.
Step 3: set the panel password
When it finishes, the installer shows a password. To change it:
pihole setpassword
The panel is at http://PI-IP/admin (for example http://192.168.1.10/admin).
Step 4: make the network use Pi-hole
Installing Pi-hole is not enough: devices have to ask it. The documentation proposes three methods, best to worst:
Option A: DNS in the router’s DHCP (recommended)
Log into the router and find the LAN or DHCP settings. Change the DNS server handed to clients to the Pi’s IP.
- Set only Pi-hole’s IP. If you add a second public DNS, many devices will use it and bypass blocking.
- Devices pick up the new DNS when they renew the connection. Disconnect and reconnect Wi-Fi, or restart them.
Careful: changing the DNS of the router’s WAN is not the same. That changes the DNS the router uses, not what it hands out.
Option B: Pi-hole as DHCP server
If the router will not let you change DNS (some ISP routers do this), Pi-hole can hand out IPs. Enable it under Settings → DHCP in the panel and disable the router’s DHCP first: two DHCP servers on one network cause conflicts.
Option C: manual DNS on each device
Last resort: set Pi-hole’s IP as DNS on each machine.
Step 5: check that it works
From any computer on the network:
nslookup doubleclick.net
If the server shown is the Pi’s IP and the address is 0.0.0.0, blocking works. You will see the query counter rise in the panel.
Manage lists
Lists are added under Lists in the panel. After adding one, update the database (gravity):
pihole -g
Tips:
- More lists is not better. Many aggressive lists break websites and apps.
- If a site stops working, check the Query Log, find the blocked domain and allow it.
Useful commands:
pihole status # service status
pihole disable 5m # disable for 5 minutes
pihole enable # enable again
pihole allow ejemplo.com
pihole deny rastreador.ejemplo.com
pihole tail # follow queries live
pihole -up # update Pi-hole
pihole repair # reinstall keeping settings
Common problems
| Symptom | Cause and fix |
|---|---|
| The query counter does not rise | The router still hands out another DNS. Check option A and reconnect devices |
| Ads still show on a phone | It has Private DNS (Android) or encrypted DNS in the browser. Turn it off |
| The whole network loses internet | The Pi is off or changed IP. That is why DHCP reservation is advised |
| An app or site does not load | A needed domain is blocked. Find it in Query Log and use pihole allow |
| The installer fails on port 53 | Another DNS server is on the Pi. Stop it |
| Odd errors after updating | pihole repair |
Frequently asked questions
Does it slow down browsing?
Not noticeably: Pi-hole also caches answers, so repeat queries are faster.
What if the Raspberry Pi turns off?
Devices cannot resolve names and it looks like there is no internet. If that is a problem, set up a second Pi-hole and hand it out as secondary DNS.



