Set up a network-wide DNS filter
ActivitiesProjects
Route a test device's DNS queries through Pi-hole and verify that it blocks the domains on your test list.
Setting up a network-wide DNS filter means running a local DNS server on your home network—commonly Pi-hole—so participating devices send their domain lookups through it. When a phone, laptop, or smart appliance asks for a domain, Pi-hole's FTL DNS server checks the name against your blocking rules. It returns a blocked response if the domain matches, answers directly from its local cache if it already has the record, or forwards an allowed uncached request to an upstream resolver and caches the reply. Because filtering happens at the DNS lookup stage, every device you want covered must actually send its DNS queries through that server.
Picking a host and installing the filter
You do not need a Raspberry Pi specifically; Pi-hole runs on a range of supported Linux hardware as long as the machine keeps a stable local IP address, whether configured statically or through a router DHCP reservation. Check the current supported operating systems and hardware prerequisites before choosing a host, since those requirements change over time. Because DNS listens on both TCP and UDP port 53, any other DNS service already running on that machine has to be stopped or resolved so the two do not conflict.
Pi-hole can be installed via a one-step shell command, a downloaded installer script, a cloned repository, or Docker. Cloning the repository or downloading the script separately lets you inspect the code before running it, whereas piping a remote installer straight into bash skips that review. During setup, you also choose where allowed uncached queries go: either an external upstream resolver or, for a more involved setup on a Debian- or Ubuntu-based host, a local recursive resolver such as Unbound running on the same device.
Pointing your network to the server
Installing the software only puts the filter on the network; client devices still have to be directed to use it. The standard approach is configuring your router's DHCP service to advertise the Pi-hole address as the network's DNS server. If your router does not let you customize its DHCP DNS setting, you can disable DHCP on the router first and turn on Pi-hole's built-in DHCP server instead, or enter the Pi-hole address manually on individual devices.
On routers with separate IPv4 and IPv6 controls, such as OPNsense, the Pi-hole IPv4 address is distributed through DHCP and its IPv6 address through router advertisements, leaving any secondary DNS field blank unless you run a second Pi-hole host. Reconnecting a device helps if a client is slow to pick up the new settings. Even after DHCP is updated, some clients ignore local settings and rely on hardcoded DNS servers. Optional firewall rules can block outbound DNS traffic to other servers, though doing so can break clients that have no fallback, and standard port-blocking rules do not address encrypted DNS such as DNS-over-HTTPS or DNS-over-TLS.
Avoiding loops and lockout traps
Two configuration mistakes can knock out name resolution across your network. First, if your router forwards DNS queries to Pi-hole, setting that same router as Pi-hole's upstream resolver creates a resolver loop; point Pi-hole to an independent upstream resolver or local recursion instead. Second, the host running Pi-hole does not automatically use itself for DNS, and keeping it separate is safer: if the host relies on its own Pi-hole and the service fails, the machine can lose the name resolution needed by repair tools that require internet access. Write down your router's previous DNS settings before making changes so you can roll back quickly during troubleshooting.
Testing client routing and fixing overblocked sites
Querying Pi-hole directly confirms that the server answers, but verifying real coverage means testing from a client device. Check which DNS servers are actually assigned to the client, query each listed IPv4 and IPv6 address for a domain on a subscribed blocklist (using `dig` on Linux or `nslookup` on Windows), and confirm that the blocked request appears in the Pi-hole Query Log.
Once the filter is active, Pi-hole's Gravity process downloads and consolidates subscribed blocklists automatically, and you can run it manually at any time with `pihole -g`. When a needed site breaks or gets overblocked, watch live lookups with `pihole tail` and run `pihole -q` to see which list or rule matched the domain. Because Pi-hole evaluates rules in priority order (exact allowlist, regex allowlist, exact denylist, subscribed allowlists, subscribed denylist, and regex denylist), adding the needed domain to the exact allowlist overrides any blocklist or regex rule and restores access.
