Network-Wide Ad Blocking with Technitium DNS on a Raspberry Pi
Technitium DNS Server is an open-source, self-hosted DNS server with built-in blocklist support. It works like Pi-hole, but it is a full recursive and authoritative DNS server, so it can also host local zones, use DNS-over-HTTPS (DoH) upstream and apply per-network access rules.
This guide runs it in Docker on a Raspberry Pi and makes it the DNS server for the whole home network. Every device that gets its settings from the router’s DHCP server is covered, including phones, TVs and consoles, and you don’t install anything on them.
Setup used in this post:
| Item | Value |
|---|---|
| Hardware | Raspberry Pi 4, wired to the router |
| OS | Raspberry Pi OS Lite (64-bit), SSH on |
| Pi IP | 192.168.0.183 (reserved on the router) |
| LAN subnet | 192.168.0.0/24 |
| Admin console | http://192.168.0.183:5380 |
If you need to flash the OS and enable SSH first, see Build a K3s Cluster on Raspberry Pi, steps 1 and 2.
1. Give the Pi a fixed IP
Every device on the network will send DNS queries to this IP, so it must not change. Use a wired connection: DNS is in the path of every request, so it should not depend on Wi-Fi signal quality.
Set a DHCP reservation (also called static lease or address binding) for the Pi’s MAC address in the router. This is better than a static IP set on the Pi itself, because the router knows the address is taken and will never give it to another device.

Reboot the Pi (or renew its lease) and check the address:
ip -4 addr show eth0
# inet 192.168.0.183/24 ... → Pi IP is 192.168.0.183, subnet is 192.168.0.0/24
Note the subnet. You need it for the recursion ACL in step 4.
2. Install Docker
ssh <user>@192.168.0.183
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
By default only root can talk to the Docker daemon socket. Adding your user to the docker group removes the need for sudo before every command. Group membership is read at login, so log out and SSH in again (or run newgrp docker) before you continue.
docker version # both Client and Server sections should print
docker compose version # the compose plugin is installed by get.docker.com
Membership in the
dockergroup is effectively root on the host. That’s fine on a single-purpose Pi, but keep it in mind.
3. Check that port 53 is free
Technitium needs to bind to port 53 on the host. Raspberry Pi OS doesn’t use a local DNS stub by default, but Ubuntu and some other images run systemd-resolved on 127.0.0.53:53, and other tools (dnsmasq, an old Pi-hole) may be listening too.
sudo ss -lntup | grep ':53 '
No output means the port is free. If systemd-resolved shows up, disable its stub listener:
sudo sed -i 's/^#\?DNSStubListener=.*/DNSStubListener=no/' /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved
4. Compose file
mkdir -p ~/technitium && cd ~/technitium
Generate a random admin password and store it in a file that only your user can read:
(umask 077; openssl rand -base64 24 > admin_password.txt)
cat admin_password.txt # save this in your password manager
The subshell keeps the umask 077 change local, so the file is created as -rw------- and your shell’s umask stays the same.
nano compose.yaml
services:
dns-server:
image: technitium/dns-server:latest
container_name: technitium-dns
hostname: dns-server
restart: unless-stopped
ports:
- '53:53/udp'
- '53:53/tcp'
- '5380:5380/tcp'
environment:
DNS_SERVER_DOMAIN: dns.home.arpa
DNS_SERVER_ADMIN_PASSWORD_FILE: /run/secrets/admin_password
DNS_SERVER_RECURSION: UseSpecifiedNetworkACL
DNS_SERVER_RECURSION_NETWORK_ACL: '127.0.0.0/8,192.168.0.0/24'
DNS_SERVER_ENABLE_BLOCKING: 'true'
DNS_SERVER_LOG_FOLDER_PATH: /var/log/technitium/dns
secrets:
- admin_password
volumes:
- dns-config:/etc/dns
- dns-logs:/var/log/technitium/dns
healthcheck:
test: ['CMD-SHELL', 'curl -fsS http://127.0.0.1:5380/api/dnsClient/healthCheck | grep -q ''"status":"ok"''']
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
sysctls:
net.ipv4.ip_local_port_range: '1024 65535'
secrets:
admin_password:
file: ./admin_password.txt
volumes:
dns-config:
dns-logs:
What the less obvious settings do:
| Setting | Why |
|---|---|
53/udp and 53/tcp | DNS uses UDP normally and falls back to TCP for large responses (truncated answers, DNSSEC). Publish both. |
5380/tcp | Web console and HTTP API. Plain HTTP, so keep it LAN-only. Never port-forward it. |
DNS_SERVER_DOMAIN | The server’s own name. home.arpa is the special-use domain reserved for home networks (RFC 8375), so it never collides with a real public domain. |
DNS_SERVER_ADMIN_PASSWORD_FILE | Reads the password from a Docker secret mounted at /run/secrets/admin_password. The password does not show up in docker inspect or in the compose file. |
DNS_SERVER_RECURSION + ..._NETWORK_ACL | Only loopback and the LAN subnet may run recursive lookups. Everyone else gets REFUSED. If port 53 is ever exposed by mistake (router port forward, UPnP), the Pi won’t become an open resolver that can be abused for DNS amplification attacks. Change 192.168.0.0/24 to your subnet from step 1. |
DNS_SERVER_ENABLE_BLOCKING | Turns on the blocking engine. The lists themselves are added in step 6. |
dns-config volume | Holds all settings, zones, blocklists and stats. This is the only state you need to back up. |
healthcheck | Lets docker compose up --wait block until the server is actually serving, and shows healthy/unhealthy in docker compose ps. |
ip_local_port_range | Widens the ephemeral port range inside the container. Outgoing queries use random source ports as a defence against cache poisoning, and a bigger range means more randomness and fewer port collisions under load. |
The
DNS_SERVER_*variables are only applied on first start, when/etc/dnsis still empty. After that, the configuration in the volume wins. To change a setting later, use the web console, or remove the volume (docker compose down -v) and start again from scratch.
Start it:
docker compose up -d --wait # returns once the healthcheck passes (~30s)
docker compose ps # STATUS should be "Up ... (healthy)"
curl -s http://localhost:5380/api/status # look for "hasDefaultCredentials":false
If it doesn’t become healthy, check docker compose logs -f.
5. Log in to the web console
Open http://192.168.0.183:5380/ and log in with:
- Username:
admin - Password: the contents of
admin_password.txt

You can change the password under Administrator → Change Password (top right). The password file is only read on first start, so after you change it the file is stale. Delete it or replace its contents so it doesn’t sit on disk; the secrets entry still needs the file to exist for docker compose up.
6. Enable blocklists
Go to Settings → Blocking:
- In Quick Add, select Default. This adds the StevenBlack unified hosts list (ads and malware domains).
- Click Save Settings at the bottom of the page.
- Click Update Now so the list downloads right away instead of at the next scheduled update. After that it refreshes automatically (every 24 hours by default).
If you want stricter blocking, you can add more lists from the same dropdown or paste a URL, for example HaGeZi or OISD. More lists block more, but they also break more sites, so start with one list and add more only when you need them.
Single domains can be allowed or blocked from the Allowed and Blocked pages. That’s the fastest fix when a list breaks a site you use.
Verify
Query the Pi directly from another machine before you point the whole network at it:
PS C:\> nslookup google.com 192.168.0.183
Server: UnKnown
Address: 192.168.0.183
Non-authoritative answer:
Name: google.com
Addresses: 2a00:1450:4010:c08::64
2a00:1450:4010:c08::71
64.233.165.138
64.233.165.113
...
PS C:\> nslookup doubleclick.net 192.168.0.183
Server: UnKnown
Address: 192.168.0.183
*** UnKnown can't find doubleclick.net: Non-existent domain
google.comresolves, so recursion and the ACL work for LAN clients.doubleclick.netreturnsNXDOMAIN(Non-existent domain), so the blocklist works. The blocked domain never leaves the Pi.Server: UnKnownis harmless.nslookupdoes a reverse (PTR) lookup on the server’s IP, and there is no PTR record for192.168.0.183.
On Linux/macOS, dig @192.168.0.183 doubleclick.net gives the same result with more detail (status, TTL, query time).
7. Encrypt upstream queries (DoH forwarders)
By default Technitium resolves names itself, starting from the root servers. That works, but every query goes over the network as plain UDP, so your ISP can see and log every domain you look up.
Forwarding to a public resolver over DNS-over-HTTPS encrypts that traffic. To the ISP it looks like normal HTTPS to Cloudflare or Quad9.
Go to Settings → Proxy & Forwarders:
- In Quick Select, pick Cloudflare (DNS-over-HTTPS) or Quad9 (DNS-over-HTTPS). Quad9 also blocks known malware domains.
- Check that Forwarder Protocol switched to HTTPS.
- Click Save Settings.

Run the nslookup google.com test again to confirm upstream resolution still works.
Trade-off: you move trust from your ISP to Cloudflare or Quad9. Both publish no-logging policies, but if you’d rather not depend on any third party, skip this step and keep full recursion.
8. Point the network at the Pi
The DNS server address reaches devices through the router’s DHCP server. Router menus differ, but look under LAN, DHCP Server or Network, not under WAN/Internet. The WAN DNS setting only controls what the router itself uses.
- Find the DNS server fields that DHCP hands out to clients.
- Set Primary DNS to
192.168.0.183. - Leave Secondary DNS empty. If the router requires a value, enter
192.168.0.183again.

Don’t use 8.8.8.8 or another public resolver as secondary. Clients don’t use the secondary only as a fallback; many operating systems send queries to both servers or switch between them. Ads would get through at random, and the problem would be hard to find.
Devices pick up the new DNS server when their DHCP lease renews. To apply it right away, reconnect to the network or renew the lease:
ipconfig /release; ipconfig /renew; ipconfig /flushdns
ipconfig /all # "DNS Servers" should show 192.168.0.183
After a few minutes the dashboard shows queries coming from all devices on the network:

Things that bypass the Pi
Some clients don’t use the DNS server from DHCP. If ads still show up on a device, check these first:
- IPv6 DNS from the router. If your router has IPv6 enabled, it may advertise its own IPv6 DNS server through Router Advertisements (RDNSS) or DHCPv6. Clients often prefer IPv6 and skip the Pi. Turn off IPv6 DNS advertisement on the router’s LAN, or set it to the Pi’s IPv6 address.
- Browser “Secure DNS”. Chrome, Edge and Firefox can use their own DoH resolver and ignore the system DNS. Set it to “use your current service provider” or turn it off.
- Android Private DNS. If it’s set to a hostname, Android sends all DNS there over TLS. Set it to Automatic or Off.
- Hardcoded DNS. Some devices (Chromecast, some smart TVs) query
8.8.8.8directly. Blocking outbound port 53 to everything except the Pi in the router firewall forces them through it, if your router supports that. - In-stream ads. YouTube and similar services serve ads from the same domains as the content. DNS blocking can’t separate them, so you still need a browser extension for those.
Operations
Updates:
cd ~/technitium
docker compose pull
docker compose up -d --wait
docker image prune -f
All settings live in the dns-config volume, so they survive container recreation.
Backup: Settings → Backup Settings in the console downloads a zip of the configuration. You can restore it on a fresh install with Restore Settings.
Single point of failure: while the Pi is down, nothing on the network can resolve names, and to users that looks like “the internet is down”. restart: unless-stopped brings the container back after a crash or reboot. If you need more than that, run a second Technitium instance on another machine and give DHCP both IPs. Both servers block, so the secondary no longer leaks ads.