Pi-hole is a network-wide ad blocker. In this guide I run it on TrueNAS SCALE so every device on your network, phones, smart TVs and consoles included, gets ads, trackers and malware domains blocked without installing anything on the devices themselves.
What you need
- A TrueNAS SCALE 24.10 (Electric Eel) or newer server with a static IP address, meaning an address that never changes. Every device will send its DNS lookups there. My TrueNAS install guide covers setting one.
- Admin access to your router, so you can change the DNS server it hands out.
- A folder for app settings, such as
/mnt/apps. Your real path includes your pool name (for example/mnt/tank/apps). - About 15 minutes.
What it is
| Platform | TrueNAS Scale (Docker custom app) |
| Ports | 53 (DNS), 80 (web UI), 443 (HTTPS) inside the container |
| Image | ghcr.io/pi-hole/pihole:latest |
| Config path | /mnt/apps/pihole/config → /etc/pihole |
| dnsmasq path | /mnt/apps/pihole/dnsmasq → /etc/dnsmasq.d (optional) |
| License | EUPL-1.2 |
DNS (Domain Name System) is the internet's phone book. Before your phone loads example.com, it asks a DNS server for that name's IP address. Pi-hole becomes that DNS server for your network. It checks every lookup against blocklists (lists of known ad and tracking domains). When a device asks for an ad domain like ads.doubleclick.net, Pi-hole answers with 0.0.0.0, an address that goes nowhere. The ad never loads.
Because this happens at the network level, every device that uses Pi-hole for DNS is covered.
This guide uses Pi-hole v6, the current major version. If you've followed older guides, note that v6 renamed most Docker settings and several commands. I've used the new names throughout.
The hard part: ports 53 and 80 are already taken
The install takes five minutes. The trouble is that Pi-hole wants two ports that TrueNAS may already be using.
Port 80. The TrueNAS web interface listens on ports 80 (HTTP) and 443 (HTTPS) by default. If you map Pi-hole's web UI to port 80 on the NAS, the app will fail to start. The fix is easy: publish Pi-hole's web UI on a different NAS port, such as 8081. The compose file below does that.
Port 53. DNS uses port 53. On a plain TrueNAS SCALE box it's usually free. On TrueNAS 25.04 (Fangtooth) with the Virtualization (Incus) service in use, Incus runs its own small DNS server on port 53 for its internal network, and Pi-hole can fail with "address already in use". Check before you deploy:
sudo ss -tulpn | grep ':53 '
No output means port 53 is free. If something is listed, the cleanest fix is to give Pi-hole its own IP address on your network so it doesn't compete with the NAS for port 53. The TrueNAS forum thread on Pi-hole and port 53 shows that approach.
Older guides tell you to stop
systemd-resolvedand delete/etc/resolv.conf. That advice is for Ubuntu and Debian desktops and servers. TrueNAS manages its own DNS settings, and changes made to the base system from the shell aren't supported and may be lost on update. Don't do it on TrueNAS.
- DNS resolution chain without Pi-hole
- DNS resolution chain with Pi-hole
- Device → Router (DNS) → Pi-hole (<nas-ip>
- 53) → Upstream DNS (1.1.1.1) → Internet
How to install it
Step 1: Check port 53
Run the ss command from the section above in System → Shell.
Check it worked: no output. If you see a process on port 53, sort that out first.
Step 2: Create directories
mkdir -p /mnt/apps/pihole/config
mkdir -p /mnt/apps/pihole/dnsmasq
Check it worked: ls /mnt/apps/pihole lists config and dnsmasq.
Step 3: Generate a password
# Generate a random password for the web UI:
openssl rand -base64 12
Save this password in your password manager. It's the admin password for the Pi-hole web interface. If you leave it out of the compose file, Pi-hole sets a random one and you'll have to reset it.
Step 4: Deploy the app
Go to Apps → Discover Apps, open the three-dot menu at the top right, choose Install via YAML, name the app pihole and paste:
services:
pihole:
image: ghcr.io/pi-hole/pihole:latest
container_name: pihole
restart: unless-stopped
environment:
- TZ=Europe/London
- FTLCONF_webserver_api_password=your_generated_password_here
- FTLCONF_dns_listeningMode=all
- FTLCONF_dns_upstreams=1.1.1.1;1.0.0.1
ports:
- "53:53/tcp"
- "53:53/udp"
- "8081:80/tcp"
volumes:
- /mnt/apps/pihole/config:/etc/pihole
- /mnt/apps/pihole/dnsmasq:/etc/dnsmasq.d
cap_add:
- NET_ADMIN
What each setting does:
FTLCONF_webserver_api_passwordis the web UI password from Step 3. (In Pi-hole v5 this wasWEBPASSWORD.)FTLCONF_dns_listeningMode=alllets Pi-hole answer queries coming from your LAN through Docker's network. (v5:DNSMASQ_LISTENING.)FTLCONF_dns_upstreamsare the upstream servers, the public DNS servers Pi-hole asks for anything it doesn't block. Separate them with a semicolon. (v5:PIHOLE_DNS_.)8081:80/tcppublishes the web UI on port 8081 of the NAS, so it doesn't clash with TrueNAS on port 80.- The
/etc/dnsmasq.dmount is only read if you also setFTLCONF_misc_etc_dnsmasq_d=true. Most new installs don't need it. NET_ADMINis only needed if you later use Pi-hole as your DHCP server.
Click Install.
Check it worked:
# Check Pi-hole is running:
docker logs pihole 2>&1 | tail -5
# Verify DNS is working (from the TrueNAS shell):
dig @127.0.0.1 google.com
dig should print an ANSWER SECTION with an IP address. From another computer, nslookup google.com <nas-ip> does the same test.
Then open http://<nas-ip>:8081/admin and sign in with the password from Step 3. There's no username.
Step 5: Point your router to Pi-hole
Until you do this, nothing on your network is using Pi-hole.
- Open your router's admin page (often
192.168.1.1or similar; check the label on the router) - Find the DNS setting for your local network. It's often under LAN or DHCP settings, sometimes under DNS Settings or WAN Settings
- Set the Primary DNS to your TrueNAS IP
- Leave the Secondary DNS empty, or put the TrueNAS IP there too
- Save, then reconnect a device to the network (or restart the router)
About the secondary DNS: devices don't save it for emergencies. Many use both servers and pick whichever answers, so a public server like 1.1.1.1 in that slot lets some ads through. The trade-off is that if the NAS goes down, DNS goes down with it. If you need a fallback, run a second Pi-hole.
Check it worked: on a phone or laptop, reconnect to Wi-Fi and browse a few sites. The Pi-hole dashboard should show queries from that device's IP, and some marked as blocked.
Configuration that matters
Upstream DNS servers
| 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 |
| OpenDNS | 208.67.222.222 |
208.67.220.220 |
Change these in Settings → DNS, or with FTLCONF_dns_upstreams in the compose file. Pi-hole sends these upstream queries as plain DNS. If you want them encrypted, you need an extra tool such as cloudflared or unbound running alongside it.
Blocklists
Pi-hole ships with one default list. You can add more:
| List | URL | What it blocks |
|---|---|---|
| Steven Black's | https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts |
Ads, malware, phishing |
| OISD Big | https://big.oisd.nl |
Ads, tracking, telemetry |
| 1Hosts (Lite) | https://cdn.jsdelivr.net/gh/badmojr/1Hosts@master/Lite/hosts.txt |
Balanced blocking |
| Peter Lowe's | https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts |
Ads and tracking |
Add lists under Lists in the web UI, then update gravity (Pi-hole's name for its combined blocklist database) with Tools → Update Gravity, or from the shell:
docker exec pihole pihole -g
More lists isn't always better. Overlapping lists slow down updates and raise the chance of breaking sites.
DHCP (optional)
DHCP is the service that hands out IP addresses (and the DNS server address) to devices when they join the network. Your router does this today.
| Setting | Recommended value | Why |
|---|---|---|
| DHCP server | Off (use your router) | Simpler setup, less to break |
| DHCP on Pi-hole | On only if you disable router DHCP | Useful if your router won't let you change DNS |
| Lease time | 24 hours | Default is fine for most networks |
If you enable DHCP on Pi-hole, disable it on your router first. Two DHCP servers on the same network cause IP conflicts. DHCP inside a bridged Docker container also needs extra network setup, so try the router route first.
Allow and deny domains
v6 calls these the allowlist and denylist (v5 said whitelist and blacklist).
| Action | When to use |
|---|---|
| Allow domain | A legitimate site is broken by Pi-hole (e.g., analytics.example.com) |
| Deny domain | An ad domain slips through the blocklist |
| Disable blocking | Temporarily, for debugging DNS issues |
Manage them under Domains in the web UI, or from the shell:
# Allow a domain:
docker exec pihole pihole allow example.com
# Deny a domain:
docker exec pihole pihole deny ads.example.com
# Disable blocking for 5 minutes:
docker exec pihole pihole disable 5m
# Re-enable blocking:
docker exec pihole pihole enable
Troubleshooting
The app won't start: "address already in use". Something holds port 53 or the web port. Run sudo ss -tulpn | grep -E ':53 |:80 '. If it's port 80, check that you mapped 8081:80 and not 80:80. If it's port 53, see the hard-part section above.
I can't log in / forgot the password. Set a new one:
docker exec -it pihole pihole setpassword
If FTLCONF_webserver_api_password is in your compose file, the container sets that value again on every start, so change it there too.
The dashboard shows no queries. Devices aren't using Pi-hole yet. Check the router's DNS setting, then reconnect the device so it picks up the new setting. On a computer, nslookup google.com shows which server answered.
Ads still show up. Check the router isn't handing out a second, non-Pi-hole DNS server. Some devices and browsers also use their own DNS (for example DNS-over-HTTPS in the browser), which skips Pi-hole. YouTube ads come from the same domains as the videos, so DNS blocking can't stop them.
A site or app is broken. Open Query Log, filter by your device, reproduce the problem, and look for blocked domains. Allow only the specific domain causing it.
What I'd tell anyone building this
-
Don't fight TrueNAS for its ports. Move Pi-hole's web UI to 8081, and if port 53 is taken, give Pi-hole its own IP instead of changing the TrueNAS base system.
-
The password is set at deploy time.
FTLCONF_webserver_api_passwordsets it. If you forget it, reset it withdocker exec -it pihole pihole setpassword. -
Do not run Pi-hole on a Raspberry Pi if you have a NAS. Pi-hole uses almost no CPU or RAM. Running it on TrueNAS means one less device to maintain, and it stays up as long as your NAS is up. The flip side: when the NAS reboots, your network loses DNS for a minute.
-
Pi-hole does not replace a firewall. It blocks DNS lookups for ad domains, but it does not block traffic at the IP level. For that, you need pfSense, OPNsense, or firewall rules on your router.
-
Blocklists update on their own. Pi-hole rebuilds gravity automatically once a week. Run
docker exec pihole pihole -gafter you add new lists. -
Allowlist carefully. If a website or app breaks, disable blocking for a few minutes to confirm Pi-hole is the cause, then allow only the domain causing the issue. Allowing too broadly defeats the purpose.
Next steps
- Set Pi-hole as the DNS server on your router's guest network too, if it has one.
- Read Homelab networking: VLANs, DNS and firewall rules for the firewall side that Pi-hole doesn't cover.
- If you're building out the rest of the homelab, the media stack guide is a good next project.
Get it
Links:
- Pi-hole official site
- Pi-hole Docker documentation
- Pi-hole Docker image on GitHub
- Pi-hole community blocklists
- Blocklist aggregator
Quick install (Docker Compose):
services:
pihole:
image: ghcr.io/pi-hole/pihole:latest
container_name: pihole
restart: unless-stopped
environment:
- TZ=Europe/London
- FTLCONF_webserver_api_password=your_generated_password_here
- FTLCONF_dns_listeningMode=all
- FTLCONF_dns_upstreams=1.1.1.1;1.0.0.1
ports:
- "53:53/tcp"
- "53:53/udp"
- "8081:80/tcp"
volumes:
- /mnt/apps/pihole/config:/etc/pihole
- /mnt/apps/pihole/dnsmasq:/etc/dnsmasq.d
cap_add:
- NET_ADMIN
After deploy:
# Verify DNS is working:
dig @<nas-ip> google.com
# Update blocklists:
docker exec pihole pihole -g
# Check status:
docker exec pihole pihole status
Open http://<nas-ip>:8081/admin, add blocklists, and point your router's DNS to the NAS IP.