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-21 17:47:25 +0200
commitc9787fb53c067ee73149431306d3a561cc37633c (patch)
tree9b9c7976eff8a97f7b67cdee5def9cd8f30aea36 /src/conf_mode/dns_forwarding.py
parent99ab24d440d4ee3969679b6c023a377c4a94b9e1 (diff)
downloadvyos-1x-c9787fb53c067ee73149431306d3a561cc37633c.tar.gz
vyos-1x-c9787fb53c067ee73149431306d3a561cc37633c.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. (cherry picked from commit 5886dd27cbc65f8cda04752bbd39a960b0887523)
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)