Filter Ads on Your Home Network with Pi-hole and Raspberry Pi (Direct Install)
If you want to help filter ads for several devices at home, you can install Pi-hole on a Raspberry Pi to filter advertising domains through DNS, without installing a separate ad blocker on every device.
If your Pi already runs Docker, follow the Docker Compose installation guide instead. Choose one installation method per host.

DNS translates website names into IP addresses. When a device asks Pi-hole for a domain, Pi-hole checks it against its blocklists. It blocks domains on the list and forwards other requests to the upstream DNS server you choose.
What you need
- A Raspberry Pi running a supported Raspberry Pi OS version and connected to your home network.
- An account that can use
sudo, and a computer or phone for testing. - Access to your router settings if you want to use Pi-hole across the home network.
This guide uses 192.168.1.10 as an example Raspberry Pi address. Replace it with your Pi’s actual address. Set a DHCP reservation on the router so the Pi keeps the same IP address; the steps depend on your router. To check its addresses, run:
hostname -I
If several addresses appear, choose the one on your home network. Also check that another service is not already using DNS port 53 or the web port Pi-hole needs. See the Pi-hole prerequisites for details.
Install Pi-hole
Connect to the Raspberry Pi directly or over SSH, then download and inspect the installer before running it. The installer changes system settings and installs software.
If curl is missing, install it first with sudo apt update and sudo apt install curl. Then download and inspect the installer:
curl -fsSL https://install.pi-hole.net -o pihole-install.sh
less pihole-install.sh
Press q to leave less. After reviewing the script, start the installation:
sudo bash pihole-install.sh
Follow the prompts, choose the network interface connected to your home network, select an upstream DNS provider for requests that are not blocked, and install the web interface when prompted. Keep the information shown at the end of installation for signing in.
Open the dashboard
From a device on the same network, open http://192.168.1.10/admin/ in a browser, replacing the IP address with your Pi’s address. To set a new password, run the following command on the Pi and follow the prompts:
pihole setpassword
The dashboard shows DNS request counts and blocked requests. Keep the web interface and DNS service accessible only from trusted networks; do not expose the DNS service to the internet.
Use Pi-hole to help block phishing sites
Besides ads and trackers, Pi-hole can block phishing and malware domains on its blocklists. You can also choose an upstream DNS provider that filters threats. When Pi-hole doesn’t block a query locally, it passes the query on for that provider to check.
- Quad9
9.9.9.9and149.112.112.112: Blocks known phishing and malware domains. If a site you normally use stops opening, check the domain in Quad9’s lookup tool to see whether it was blocked and which list flagged it. - Cloudflare
1.1.1.2and1.0.0.2: Also blocks phishing and malware domains, but uses a different list. To filter adult sites as well, use1.1.1.3and1.0.0.3instead.
If phishing is your main concern, Quad9 is a good starting point. Pick one pair rather than mixing providers: Pi-hole can send queries to either server, and each may block different domains.
In Pi-hole’s admin page, go to Settings → DNS, select only the pair you want, and click Save. If the pair isn’t listed, enter the addresses under Custom DNS servers and clear the old selections. This changes where Pi-hole forwards queries. Your test computer should still point to the Pi’s IP address.
Both services filter by domain. A brand-new phishing site may not be listed yet, and DNS can’t single out a phishing page hosted alongside normal pages on the same domain.
Try it on one device first
Before changing the router, write down the test device’s current DNS settings. Change the DNS setting for its Wi-Fi or LAN connection to the Pi’s IP address, such as 192.168.1.10. The menu depends on the operating system. Reconnect to the network and try opening a normal website.
On a computer with nslookup, check whether the Pi answers DNS queries, replacing the IP address with the Pi’s actual address:
nslookup example.com 192.168.1.10
An IP address in the answer shows that the Pi answered this query. Next, open a website from the test device and check the dashboard’s Query Log for requests from that device and entries marked as blocked. This nslookup command alone does not prove the device uses Pi-hole as its primary DNS server, so check the Query Log as well.
If no requests appear, check the Pi’s IP and the device’s DNS settings. DNS over HTTPS or Private DNS may bypass Pi-hole, and the router may distribute IPv6 DNS settings separately.
If you chose Quad9, you can query its documented test name without opening a harmful website. Replace the example IP with your Pi’s IP address.
dig @192.168.1.10 isitblocked.org A
Quad9’s example returns NXDOMAIN with AUTHORITY: 0. Check the Query Log to see that the upstream server blocked the query rather than a local Pi-hole list. An NXDOMAIN response alone can also mean the domain doesn’t exist.
Use it across the home network
Once the single-device test works, open the router’s LAN or DHCP settings and note the existing values. Set the DNS server distributed by DHCP to the Pi’s IP address, rather than changing only the router’s WAN DNS setting. Reconnect client devices or renew their DHCP leases, then check the Query Log again. Menu names vary between routers.
If a public DNS server is configured as a secondary DNS server, clients may use it and bypass filtering. Check IPv6 DNS distribution separately according to your router’s capabilities. If the Pi is off or has a problem, devices relying on it for DNS may not be able to open websites. Make sure you know how to restore the previous settings before changing the whole network.
When a website stops working
If a website or app has problems after enabling Pi-hole, check the Query Log around the time of the problem. If you find a blocked domain and are sure it is needed, add it to the allowlist through the Domains page and try again. Check unfamiliar domains before allowing them.
To stop using Pi-hole, restore the previous DNS settings on the device or router DHCP settings, then reconnect or renew the lease. Devices that received the old settings may take some time to pick up the change.
Limitations
Pi-hole filters by domain name, so it cannot always separate ads from the main content, including some YouTube ads. Apps using their own DNS or encrypted DNS may bypass filtering, and devices outside the home network will not automatically use this Pi-hole.
References: Pi-hole Installation, Prerequisites and Post-Install.