If you're like me and you want to resolve alternative DNS namespaces (like OpenNIC), need split-routing resolution for internal domains, and still want DNSSEC‑validated queries for the public internet, you've probably run into the limitations of systemd-resolved. After struggling with its inflexible routing, I finally made the switch to Knot Resolver.
In this post, I'll explain why I moved away from systemd-resolved, how I set up Knot Resolver on Arch Linux, and what my final configuration looks like.
The Problem: systemd-resolved just couldn't cut it#
My goal was simple:
- Use Quad9 (with DNSSEC) for all regular domains (
.com,.org, etc.). - Use a set of OpenNIC‑friendly DNS servers (over TLS) for OpenNIC's alternative TLDs like
.bbs,.chan,.geek, etc. - Use my local router (192.168.1.1) for my internal domain
.internal.
With systemd-resolved, I initially tried the following (invalid) configuration:
# /etc/systemd/resolved.conf.d/dns_servers.conf
#
# Default resolver, using Quad9
[Resolve]
DNS=9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
Domains=~.
# OpenNIC TLDs
[Resolve]
DNS=51.158.108.203 51.77.149.139 2001:41d0:404:200::976
Domains=~bbs ~chan ~cyb ~dyn ~epic ~geek ~gopher ~indy ~libre ~neo ~null ~o ~oss ~oz ~parody ~pirate
# Internal / local domain
[Resolve]
DNS=192.168.1.1
Domains=~internalThis doesn't work. systemd-resolved will merge all [Resolve] section in the global namespace.
➜ resolvectl status
Global
Protocols: -LLMNR -mDNS DNSOverTLS=opportunistic DNSSEC=no/unsupported
resolv.conf mode: stub
Current DNS Server: 149.112.112.112#dns.quad9.net
DNS Servers: 9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net 51.158.108.203 51.77.149.139 2001:41d0:404:200::976 192.168.1.1
Fallback DNS Servers: 9.9.9.9#dns.quad9.net 2620:fe::9#dns.quad9.net 1.1.1.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 8.8.8.8#dns.google 2001:4860:4860::8888#dns.google
DNS Domain: ~. ~bbs ~chan ~cyb ~dyn ~epic ~geek ~gopher ~indy ~libre ~neo ~null ~o ~oss ~oz ~parody ~pirate ~internal
Link 3 (virbr0)
Current Scopes: DNS
Protocols: +DefaultRoute -LLMNR -mDNS DNSOverTLS=opportunistic DNSSEC=no/unsupported
Current DNS Server: 9.9.9.9
DNS Servers: 9.9.9.9 149.112.112.112 51.158.108.203 51.77.149.139 2620:fe::fe 2620:fe::9 2001:41d0:404:200::976
Default Route: yes
Link 2 (enp9s0)
Current Scopes: none
Protocols: -DefaultRoute -LLMNR -mDNS DNSOverTLS=opportunistic DNSSEC=no/unsupported
Default Route: noThe result is you can't assign different DNS servers to different domain suffixes. The Domains= directive is only used for search domains and for routing queries when a domain matches a suffix, but it does not allow you to specify a separate set of upstream servers per suffix. You get one global set of DNS servers, period.
The only way to make it work in theory, is to assign one forwarding route per network interface, but if you want the rules to apply globally, it's not possible.
I needed a proper split‑routing DNS forwarder and that's where Knot Resolver comes in.
Knot Resolver#
Knot Resolver (a.k.a. kresd) is a modern, high‑performance DNS resolver that supports subtree‑based forwarding, TLS‑encrypted transport, per‑forwarder DNSSEC settings, and caching. It's flexible and is packaged for Arch Linux in the official repositories.
Installation#
On Arch, it's a one‑liner:
sudo pacman -S knot-resolverThis installs the daemon (kresd), the configuration file /etc/knot-resolver/config.yaml, and a systemd service (knot-resolver.service).
Crafting the configuration#
My final config.yaml is structured around three forwarding rules, each tied to a specific subtree of the DNS namespace. Let's break it down.
Global settings#
workers: 2
network:
listen:
- interface: lo
do-ipv4: true
do-ipv6: true
logging:
level: info
local-data:
addresses-files:
- /etc/hostsI set 2 worker threads, listen only on the loopback interface (since I only want a local resolver and do not expose it to the rest of my network), enable both IPv4/IPv6, and load the system's /etc/hosts file for local overrides.
OpenNIC alternative TLDs#
forward:
- subtree: # OpenNIC alternative TLDs
- bbs
- chan
- cyb
- dyn
- epic
- geek
- gopher
- indy
- libre
- neo
- 'null'
- o
- oss
- oz
- parody
- pirate
servers:
- address: [ 2a03:4000:2b:1217::1@853, 193.31.24.55@853 ] # DE
transport: tls
hostname: dns.n4x2.com # ns3.de.dns.opennic.glue
- address: [ 2a03:4000:006b:0191:9825:1cff:fe34:0bbe@853, 152.53.15.127@853 ] # DE
transport: tls
hostname: jabber-germany.de # ns28.de.dns.opennic.glue
- address: [ 2003:a:133:1500::8@65533, 217.91.179.72@65533 ] # DE
transport: tls
hostname: dot.kekew.info # ns27.de.dns.opennic.glue
- address: [ 2003:a:64b:3b00::4@65533, 80.152.203.134@65533 ] # DE
transport: tls
hostname: dot.kekew.info # ns2.de.dns.opennic.glue
- address: [ 2003:a:812:5700::6@65533, 80.153.146.105@65533 ] # DE
transport: tls
hostname: dot.kekew.info # ns4.de.dns.opennic.glue
options:
dnssec: false # Most OpenNIC domains are unsignedHere, I list all the OpenNIC TLDs under subtree. For each, Knot Resolver will forward queries to one of the listed TLS servers. I've chosen several German servers from the OpenNIC project (nearest to me), all supporting DNS‑over‑TLS (DoT). The default port for DoT is 853 so we have to specify the custom 65533 port with @ for some servers.
Internal local domain#
- subtree: internal # Local DNS
servers:
- address: [ fe80::6e38:a1ff:febd:a6f, 192.168.1.1 ]
options:
dnssec: falseAnything ending in .internal is sent straight to my router's DNS (IPv4 and IPv6). Since it's a local resolver, DNSSEC is off.
Default catch‑all (everything else)#
- subtree: . # Forward everything else to Quad9
servers:
- address: [ 2620:fe::fe, 9.9.9.9, 2620:fe::9, 149.112.112.112 ]
transport: tls
hostname: dns.quad9.net
options:
dnssec: trueThe final rule matches the root zone (.), so any query not matched by the previous subtrees ends up here. I forward to Quad9's IP addresses (IPv4 and IPv6) over TLS, with full DNSSEC validation enabled. This gives me a secure, privacy‑respecting default.
Making it the system resolver#
Before launching the resolver, validate teh configuration:
kresctl validate --strictAfter saving the configuration, I enabled and started the service:
sudo systemctl enable knot-resolver.service
sudo systemctl start knot-resolver.serviceBy default, Knot Resolver listens on 127.0.0.1:53 and ::1:53. I then updated /etc/resolv.conf to point to 127.0.0.1. Then made it immutable (sudo chattr +i /etc/resolv.conf) to avoid other software to overwrite it.
$ cat /etc/resolv.conf
nameserver ::1
nameserver 127.0.0.1
options edns0 trust-adTo completely remove systemd-resolved from the picture:
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolvedFinal thoughts#
Since switching, my DNS resolution has been reliable and predictable. The configuration is now self‑documenting, and I can easily add more TLDs or switch upstream servers without jumping through hoops.
To make queries, you can replace resolvectl query with kdig (of course drill stilkl works).
If you're on Arch (or any Linux distribution) and you find yourself battling systemd-resolved's limitations, I highly recommend giving Knot Resolver a try. It's a professional‑grade tool that works beautifully even for home power‑users.
systemd-resolved is simple to install and easy to configure but has many limitations and is not supporting many advanced options. However, it's still a very solid option for simple needs.
Disclaimer: if you find the configuration on ArchLinux's wiki very looking alike, it's because I'm the one that contributed it.