filterdns: Why I Wrote My Own DNS Filter

A museum network has many kinds of users. Staff machines need full internet. Exhibition installations need almost none. Public Wi-Fi needs ads and trackers blocked. Kiosk PCs should only talk to one upstream. Now and then an artwork needs an unblockable allowlist of three specific domains. That is one DNS server with many policies.
I tried Pi-hole, AdGuard Home and NextDNS. All of them assume one policy per server. You can run several instances and route traffic between them, but then you maintain a fleet instead of a service. So I wrote filterdns.
What it does
It speaks several protocols on the front and picks a profile on the back.
- DoH (DNS-over-HTTPS, port 443): profile from the Host header subdomain (
work.dns.example,kiosk.dns.example, …) - DoT (DNS-over-TLS, port 853): profile from the TLS SNI
- Legacy DNS (port 53, UDP and TCP): profile from a source-IP lookup in the devices table
Each profile has the standard things: blocklist subscriptions (Hagezi, StevenBlack, OISD), allowlists, query logs, stats. You can pause filtering for 5/15/30/60 minutes when something legitimate wants to load. Maintenance mode blocks everything except a small manual allowlist, which is useful for kiosk installations during opening hours.
Profiles are self-service. Users without admin access can create them, protected by a bcrypt password per profile. Nobody from IT has to be involved when someone sets up a “kids’ tablet, no social media” profile.
Tech choices
- Python 3.14 + Poetry, recent enough for the async improvements
- Async stack: Quart on Hypercorn for HTTP/2 and concurrency
- DNS:
dnspythonfor the protocol handling - DB: PostgreSQL with
asyncpg, migrations via Alembic - Frontend: SvelteKit
- Cache: in-process, versioned profile cache
- Deploy: Docker Compose
It fits in one repo and one stack. There is no Redis for the cache, no separate worker process and no message queue. Every request is async, the cache lives in the process, and PostgreSQL is the source of truth.
Why not an existing tool
Pi-hole works well for one network. AdGuard Home works if you don’t need legacy DNS. NextDNS works if you trust a SaaS with the query log. None of them does per-profile filtering on the same box across DoH, DoT and port 53 with self-service profile creation.
There is also the museum reason. When a service falls over five minutes before the doors open, I want to be reverting my own decisions, not someone else’s plugin system.
Open source
github.com/zkmkarlsruhe/filterdns.
If you run a small institution with several policies and don’t want a fleet, try it. If you are at a larger institution with the same problem, tell me how your setup looks.