Set up SecDNS on OPNsense
OPNsense ships with Unbound, which supports DoT upstreams natively. Forwarding to SecDNS protects every client behind the firewall with a single configuration change.
What you will need
- A SecDNS account
- An OPNsense 23.7 or newer install with Unbound enabled
- Admin access to the web UI
- The SecDNS anycast resolver IP and the hostname
dns.secdns.io
Setup steps
- Create a device in SecDNS. Sign in, open Devices and add a new OPNsense device. Copy the anycast resolver IP and the DoT hostname. [screenshot placeholder]
- Open Unbound general settings. In the OPNsense web UI go to Services, Unbound DNS, General. Confirm Unbound is enabled and listening on the LAN interface. [screenshot placeholder]
- Enable DNSSEC and forwarding mode. Tick DNSSEC and Query Forwarding so Unbound stops doing local recursion. Apply changes.
- Open DNS over TLS. Go to Services, Unbound DNS, DNS over TLS (or Query Forwarding, depending on the OPNsense version). Add a new server, paste the SecDNS anycast IP, set the port to 853 and the verify hostname to
dns.secdns.io. - Disable upstream resolvers in System DNS. Open System, Settings, General. Remove every DNS server other than
127.0.0.1. Untick Allow DNS server list to be overridden by DHCP so the WAN cannot inject ISP DNS. - Apply and test. Apply Unbound changes. From any LAN client run
dig +short whoami.cloudflare TXT @<opnsense-lan-ip>to confirm responses originate from SecDNS.
Verify it works
On OPNsense run drill -k <key> @127.0.0.1 dnssec-name-and-shame.com to confirm DNSSEC works. From a LAN client visit https://dnscheck.tools and confirm the upstream is SecDNS. On the SecDNS dashboard the device Live Logs panel should start filling within seconds.
Troubleshooting
- Unbound fails to start after the change. Check System, Log Files, Resolver for a TLS handshake error. Verify you typed
dns.secdns.ioexactly, including the trailing TLD, in the verify hostname field. - Latency spikes on first queries. Increase Unbound's outgoing TCP buffers (Services, Unbound DNS, Miscellaneous) and confirm
Use Outgoing Interfacesis set to WAN. - Some clients still use ISP DNS. Block outbound port 53 and 853 from the LAN to anything other than the firewall, so devices cannot bypass Unbound.
- DNSSEC validation fails on bogus domains. This is the desired behaviour. Configure SecDNS to allow specific domains rather than disabling DNSSEC.
Notes
If you run HA with CARP, configure DoT on both nodes and synchronise the Unbound config via XMLRPC so failover preserves SecDNS forwarding.