Opnsense Moved to Kea dhcp and Bind
Opnsense moved to Kea dhcp, with this move it is finally possible to use Bind as name server, with the possibility to dynamically update the named from the dhcp server.
It is assumed that you are familiar with the ‘bind’ (named) configuration. You really do need to be familiar with pretty much all the fields in the zone definitions.
Kea DHCP
Services: Kea DHCP: DDNS Agent
Enable this agent, the bind address should be 127.0.0.1 and the bind port the same as the one in Bind, in my case 9530
Look for controls { in the /usr/local/etc/namedb/named.conf, there you will find the same values, they must match.
in the subnets: Edit subnet
Set all fields:
DNS forward zone: your internal domain name.DNS qualifying suffix: your internal domain name.DNS server address: the ip address for opnsense it that subnetTSIG key name: the exact name as innamed.confat thekeyblock name . Mostlyrndc-key.TSIG secret: the same as thesecretfield in the key block.TSIG algorithm: the same as thealgorithmfield in the key block.
Bind (named)
The listen port must be 53 this is hard-coded into Opnsense to mo make the dhcp updates to named work!
BIND: Configuration: General tab
In the BIND: Configuration screen:
Listen Port: 53DNS Forwarders: just add a bunch, or just google: `8.8.8.81
BIND: Configuration: Primary Zones
This is the fun part, here you should add the reverse <revers ip address>.in-addr.arpa zone. this one maps the numbers to the names.
And the forward zone, your internal domain name.
at the opnsense shell
Next edits are in /usr/local/opnsense/service/templates/OPNsense/Bind/named.conf
Added to in the options { block:
response-policy { zone "rpz.local"; };
And outside the options block:
};
zone "rpz.local" {
type master;
file "/usr/local/etc/namedb/master/rpz.local.db";
allow-query { localhost; };
allow-transfer { none; };
};
{% if helpers.exists('OPNsense.bind.general.rndcalgo') and helpers.exists('OPNsense.bind.general.rndcsecret') %}
key "rndc-key" {
$TTL 3600
@ IN SOA localhost. root.localhost. (
2026102701 ; Serial (YYYYMMDDNN)
3600 ; Refresh
600 ; Retry
864000 ; Expire
600 ) ; Minimum TTL
IN NS localhost.
; 1. Block a domain completely (Returns NXDOMAIN)
bad-actor.com IN CNAME .
*.bad-actor.com IN CNAME .
; 2. Redirect a domain to a local IP (walled garden / sinkhole)
gamingsite.com IN A 192.168.1.50
*.gamingsite.com IN A 192.168.1.50
; 3. Whitelist a domain (Bypass subsequent blocklists using PASSTHRU)
false-positive.com IN CNAME rpz-passthru.
After having saved in the Opnsense Bind GUI. Check again at the opnsense ssh shell:
named-checkconf /usr/local/etc/namedb/named.conf
This should not give any errors.