dns/bind: add Response Policy Zone (RPZ) support#5399
Open
mbedworth wants to merge 1 commit intoopnsense:masterfrom
Open
dns/bind: add Response Policy Zone (RPZ) support#5399mbedworth wants to merge 1 commit intoopnsense:masterfrom
mbedworth wants to merge 1 commit intoopnsense:masterfrom
Conversation
Adds native RPZ configuration to the os-bind plugin with a dedicated
settings tab in the GUI.
The DNSBL feature already uses response-policy inside options{}, but
there is no way to configure a standalone RPZ (e.g. a local blocklist
fed by an external updater) without manually editing named.conf, which
is overwritten on every service restart.
New files:
- Rpz.xml / Rpz.php: model mounted at //OPNsense/bind/rpz
- RpzController.php: REST API via ApiMutableModelControllerBase
(GET /api/bind/rpz/get, POST /api/bind/rpz/set)
- forms/rpz.xml: GUI form definition
Modified files:
- GeneralController.php: expose rpzForm to the view
- general.volt: add RPZ tab between DNSBL and ACLs; wire up
mapDataToFormUI and saveAct_rpz click handler
- named.conf template: emit response-policy inside options{} and
the zone declaration when RPZ is enabled and a zone name is set
Configuration fields:
- enabled: on/off toggle
- zone: zone name (file resolved to /usr/local/etc/namedb/primary/<zone>.db)
- policy: nxdomain | nodata | passthru | drop | tcp-only (optional override)
- break_dnssec: allow RPZ rewrites over DNSSEC-signed responses
Tested on OPNsense 25.1 with BIND 9.20 and Hagezi Light blocklist
(137,674 entries). NXDOMAIN confirmed for blocked domains; normal
resolution unaffected.
Member
|
@mbedworth can you please use our PR template? |
Contributor
Author
|
The PR description has been updated to use the standard template (checkboxes, "Describe the problem" / "Describe the proposed solution" sections). Let me know if anything else needs adjusting before review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important notices
Before you submit a pull request, we ask you kindly to acknowledge the following:
If AI was used, please disclose:
Describe the problem
The BIND plugin already supports DNSBL-based response-policy zones, but there is no way to configure a standalone RPZ (e.g. a local blocklist maintained by an external update script) without manually editing
named.conf. Becausenamed.confis regenerated by the configd template engine on every service restart and OS update, manual edits do not survive.The
response-policydirective must appear inside theoptions {}block, which means it cannot be injected via a top-levelincludefile fromnamed.conf.d/.Describe the proposed solution
Adds a native RPZ settings tab to the BIND GUI (between DNSBL and ACLs) and wires it through the standard OPNsense MVC/API stack:
models/OPNsense/Bind/Rpz.xml//OPNsense/bind/rpzmodels/OPNsense/Bind/Rpz.phpApi/RpzController.php/api/bind/rpz/get,/api/bind/rpz/set)forms/rpz.xmlGeneralController.phprpzFormto the viewgeneral.voltnamed.conf(template)response-policyinsideoptions {}and zone declarationConfiguration fields
/usr/local/etc/namedb/primary/<zone>.dbnxdomain|nodata|passthru|drop|tcp-only(optional; omit to use zone's own CNAME records)Coexistence with DNSBL
When both DNSBL and RPZ are enabled, two separate
response-policystatements are emitted — one for DNSBL zones and one for the RPZ zone. BIND supports multipleresponse-policystatements.Testing
Tested on OPNsense 25.1 with BIND 9.20:
rpz.localzone and Hagezi Light blocklist (137,674 entries)named-checkconfpasses cleanlyNXDOMAINwithrpz.localin the authority sectionconfigctl bind restartRelated issue
N/A