summaryrefslogtreecommitdiff
path: root/src/conf_mode/dns_forwarding.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-07-14 10:59:07 +0200
committerChristian Poessinger <christian@poessinger.com>2019-07-14 10:59:07 +0200
commit5886dd27cbc65f8cda04752bbd39a960b0887523 (patch)
treed5343a598c017718ba3dd082807082f43f10a2ac /src/conf_mode/dns_forwarding.py
parentfc20c5aac8e64b58e8c7930abf2beb78455dc2f7 (diff)
downloadvyos-1x-5886dd27cbc65f8cda04752bbd39a960b0887523.tar.gz
vyos-1x-5886dd27cbc65f8cda04752bbd39a960b0887523.zip
[dns-forwarding] T1333: handle domain forward and general recursion in one configuration line
In the past we used the PowerDNS cofniguration option forward-zones and forward-zones-recurse, but only the latter one sets the recursion bit in the DNS query. Thus all recursions have been moved to this config statement.
Diffstat (limited to 'src/conf_mode/dns_forwarding.py')
-rwxr-xr-xsrc/conf_mode/dns_forwarding.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py
index aab389074..3ca77adee 100755
--- a/src/conf_mode/dns_forwarding.py
+++ b/src/conf_mode/dns_forwarding.py
@@ -65,21 +65,19 @@ local-address={{ listen_on | join(',') }}
# dnssec
dnssec={{ dnssec }}
-{% if name_servers -%}
-# name-server
-forward-zones-recurse=.={{ name_servers | join(';') }}
-{% else %}
-# no name-servers specified - start full recursor
-{% endif %}
-
-# domain ... server ...
-{% if domains -%}
-
-forward-zones-recurse={% for d in domains %}
+# forward-zones / recursion
+#
+# statement is only inserted if either one forwarding domain or nameserver is configured
+# if nothing is given at all, powerdns will act as a real recursor and resolve all requests by its own
+#
+{% if name_servers or domains %}forward-zones-recurse=
+{%- for d in domains %}
{{ d.name }}={{ d.servers | join(";") }}
-{{- "," if not loop.last -}}
-{% endfor %}
-
+{{- ", " if not loop.last -}}
+{%- endfor -%}
+{%- if name_servers -%}
+{%- if domains -%}, {% endif -%}.={{ name_servers | join(';') }}
+{% endif %}
{% endif %}
"""
@@ -248,7 +246,6 @@ def generate(dns):
return None
tmpl = jinja2.Template(config_tmpl, trim_blocks=True)
-
config_text = tmpl.render(dns)
with open(config_file, 'w') as f:
f.write(config_text)