Skip to content

dns/bind: add native DNS-over-TLS (DoT) server support#5424

Open
mbedworth wants to merge 2 commits intoopnsense:masterfrom
mbedworth:bind-dot-listen-support
Open

dns/bind: add native DNS-over-TLS (DoT) server support#5424
mbedworth wants to merge 2 commits intoopnsense:masterfrom
mbedworth:bind-dot-listen-support

Conversation

@mbedworth
Copy link
Copy Markdown
Contributor

@mbedworth mbedworth commented May 2, 2026

Important notices

Before you submit a pull request, we ask you kindly to acknowledge the following:

If AI was used, please disclose:

  • Model used: n/a
  • Extent of AI involvement: AI assistance was used for code review and testing.

Describe the problem

The os-bind plugin has no GUI support for accepting incoming DNS-over-TLS connections (RFC 7858). BIND 9.18+ supports a native tls configuration clause and per-listener TLS on arbitrary ports, but there is no way to configure this through the plugin. Users who want to serve DoT to LAN clients have no supported path on OPNsense.

Note: this is the server (listen) side of DoT. The forwarding side (outbound DoT to upstream resolvers) is covered by PR #5391.


Describe the proposed solution

Add three new fields to the BIND general settings model and form:

  • dotenable (BooleanField) — enable/disable the DoT listener
  • dotport (PortField, default 853) — port to listen on
  • dotcertificate (CertificateField) — certificate from System > Trust > Certificates
File Role
models/OPNsense/Bind/General.xml Adds the three fields; bumps model version to 1.0.13
controllers/OPNsense/Bind/forms/general.xml Adds "DNS over TLS (Incoming)" section
service/templates/OPNsense/Bind/named.conf Emits tls dot-tls {} stanza and conditional listen-on port 853 tls dot-tls lines
scripts/OPNsense/Bind/generate_certs.php (new) Reads dotcertificate refid from config, writes /var/etc/named/dot.crt and dot.key via OPNsense\Trust\Store::getCertificate()
service/conf/actions.d/actions_bind.conf Adds [certsetup] action; prepends cert write to [start] and [restart]

The named.conf template emits a tls dot-tls stanza before the options {} block and adds listen-on port <dotport> tls dot-tls lines for each configured IPv4/IPv6 listen address when dotenable is set. The same listen addresses used for plain DNS are reused for DoT.

Because /var/etc/ is a tmpfs ramdisk, cert files do not survive reboots. The generate_certs.php script is called at the start of the [start] and [restart] configd actions to ensure the files are always present before named reads its configuration. A standalone [certsetup] action is also provided.

Testing

Tested on OPNsense 26.1 with BIND 9.20, wildcard Let's Encrypt certificate:

  • named-checkconf passes cleanly
  • openssl s_client -connect <ip>:853 shows the configured certificate
  • dig +tls @<ip> -p 853 google.com resolves correctly on all configured listen addresses (IPv4 and IPv6)
  • Configuration and cert files survive configctl bind restart
  • Plain DNS on port 53 and DoH on port 8053 are unaffected

Related issue

N/A

Fix critical syntax error in opnsense-fw active response script that prevents IPs from being added to the __wazuh_agent_drop alias.

## Problem
The script contains invalid Python syntax - a variable assignment inside a dictionary literal:
```python
"parameters":{
   unique_key = "%s-%s" % (...)  # Invalid Python syntax
   "keys": [unique_key]
}
```

This causes the script to fail with a SyntaxError on all 'add' commands, meaning attacking IPs are never blocked.

## Changes
- Move unique_key assignment outside dictionary literal (fixes SyntaxError)
- Fix typo: 'even' -> 'event' in error message
- Add debug logging for easier troubleshooting

## Testing
- Verified syntax with `python3 -m py_compile`
- Tested active response add/delete operations on OPNsense 26.1
Add GUI configuration for incoming DNS-over-TLS connections (RFC 7858).
BIND 9.18+ supports a native tls clause, but the plugin had no way to
configure it. This adds three fields to the general settings model and
form: dotenable, dotport (default 853), and dotcertificate.

A new generate_certs.php script reads the selected certificate from the
OPNsense trust store and writes the PEM files to /var/etc/named/ before
named starts. The configd [start] and [restart] actions are updated to
call this script first, ensuring cert files are present on every boot
(since /var/etc/ is a tmpfs ramdisk). A standalone [certsetup] action
is also added for on-demand use.

The named.conf template emits a tls dot-tls stanza and listen-on lines
for port 853 when dotenable is set, reusing the existing listen addresses.

Requires BIND 9.18+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant