Skip to content

Commit 2da9b7f

Browse files
dns/bind: Forwarding feature expansion
Expands the forwarding feature set by: 1. Adding global "forward only" option to forwarders 2. Adding "forward only" option to forward zones 3. Improving forward zone dialog help expansion and reformatting Signed-off-by: benyamin-codez <[email protected]>
1 parent dc0d1c3 commit 2da9b7f

File tree

6 files changed

+59
-6
lines changed

6 files changed

+59
-6
lines changed

dns/bind/src/opnsense/mvc/app/controllers/OPNsense/Bind/forms/dialogEditBindForwardDomain.xml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,39 @@
99
<id>domain.domainname</id>
1010
<label>Zone Name</label>
1111
<type>text</type>
12-
<help>Set the name for this zone. Both forward and reverse zones may be specified, i.e. example.com or 0.168.192.in-addr.arpa.</help>
12+
<help><![CDATA[
13+
Set the name for this zone.
14+
<br/>Both forward and reverse zones may be specified.
15+
<br/>Examples include:
16+
<br/>example.com
17+
<br/>0.168.192.in-addr.arpa
18+
]]></help>
19+
</field>
20+
<field>
21+
<id>domain.forwardonly</id>
22+
<label>Forward Only</label>
23+
<type>checkbox</type>
24+
<help><![CDATA[
25+
Disables recursion if forwarding fails.
26+
<br/>The default is to attempt forwarders first and only perform
27+
<br/>recursive lookups if forwarding fails. This setting is only
28+
<br/>meaningful if the list of forwarders is not empty.
29+
<br/>Can be used to override global forwarding behaviour for this
30+
<br/>domain by specifying the same servers below.
31+
<br/>This directive is explictily set to either forward only; or
32+
<br/>forward first; to avoid any furtherance of doubt.
33+
]]></help>
1334
</field>
1435
<field>
1536
<id>domain.forwardserver</id>
16-
<label>Primary IP</label>
37+
<label>Forwarder IPs</label>
1738
<style>tokenize</style>
1839
<type>select_multiple</type>
1940
<allownew>true</allownew>
20-
<help>Set the IP address of server to forward requests to.</help>
41+
<help><![CDATA[
42+
Set any combination of IPv4 and IPv6 addresses for which to
43+
<br/>forward queries to for this domain.
44+
<br/>Used to override global forwarders for this domain.
45+
]]></help>
2146
</field>
2247
</form>

dns/bind/src/opnsense/mvc/app/controllers/OPNsense/Bind/forms/general.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,24 @@
6161
<advanced>true</advanced>
6262
<help>Specify the IPv6 address used as a source for zone transfers.</help>
6363
</field>
64+
<field>
65+
<id>general.forwardonly</id>
66+
<label>Forward Only</label>
67+
<type>checkbox</type>
68+
<advanced>true</advanced>
69+
<help><![CDATA[
70+
Disables recursion if forwarding fails.
71+
<br/>The default is to attempt forwarders first and perform recursive lookups if forwarding fails.
72+
<br/>Only meaningful if the list of forwarders is not empty.
73+
]]></help>
74+
</field>
6475
<field>
6576
<id>general.forwarders</id>
66-
<label>DNS Forwarders</label>
77+
<label>Forwarders</label>
6778
<style>tokenize</style>
6879
<type>select_multiple</type>
6980
<allownew>true</allownew>
70-
<help>Set one or more hosts to send your DNS queries if the request is unknown.</help>
81+
<help>Set any combination of IPv4 and IPv6 addresses to forward queries to when the answer is unknown.</help>
7182
</field>
7283
<field>
7384
<id>general.filteraaaav4</id>

dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Domain.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<primaryip type="NetworkField">
2222
<AsList>Y</AsList>
2323
</primaryip>
24+
<forwardonly type="BooleanField">
25+
<Default>0</Default>
26+
<Required>Y</Required>
27+
</forwardonly>
2428
<forwardserver type="NetworkField">
2529
<AsList>Y</AsList>
2630
</forwardserver>

dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/General.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
<Default>53530</Default>
4646
<Required>Y</Required>
4747
</port>
48+
<forwardonly type="BooleanField">
49+
<Default>0</Default>
50+
<Required>Y</Required>
51+
</forwardonly>
4852
<forwarders type="NetworkField">
4953
<AsList>Y</AsList>
5054
</forwarders>

dns/bind/src/opnsense/mvc/app/views/OPNsense/Bind/general.volt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
<tr>
201201
<th data-column-id="enabled" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
202202
<th data-column-id="domainname" data-type="string" data-visible="true">{{ lang._('Zone') }}</th>
203+
<th data-column-id="forwardonly" data-type="string" data-formatter="boolean" data-visible="true">{{ lang._('Forward Only') }}</th>
203204
<th data-column-id="forwardserver" data-type="string" data-visible="true">{{ lang._('Forwarder IPs') }}</th>
204205
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
205206
<th data-column-id="commands" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>

dns/bind/src/opnsense/service/templates/OPNsense/Bind/named.conf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ options {
3939
{% endif -%}
4040

4141
{% if helpers.exists('OPNsense.bind.general.forwarders') and OPNsense.bind.general.forwarders != '' %}
42-
forwarders { {{ OPNsense.bind.general.forwarders.replace(',', '; ') }}; };
42+
{% if helpers.exists('OPNsense.bind.general.forwardonly') and OPNsense.bind.general.forwardonly == '1' %}
43+
forward only
44+
{% endif -%}
45+
forwarders { {{ OPNsense.bind.general.forwarders.replace(',', '; ') }}; };
4346
{% endif -%}
4447

4548
{% if helpers.exists('OPNsense.bind.dnsbl.enabled') and OPNsense.bind.dnsbl.enabled == '1' %}
@@ -154,6 +157,11 @@ zone "rpzbing" { type primary; file "/usr/local/etc/namedb/primary/bing.db"; not
154157
zone "{{ domain.domainname }}" {
155158
type {{ domain.type }};
156159
{% if domain.type == 'forward' %}
160+
{% if domain.forwardonly == '1' %}
161+
forward only;
162+
{% else %}
163+
forward first;
164+
{% endif %}
157165
forwarders { {{ domain.forwardserver.replace(',', '; ') }}; };
158166
{% elif domain.type == 'secondary' %}
159167
{% if domain.transferkey is defined %}

0 commit comments

Comments
 (0)