summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-05-31 15:49:28 +0200
committerGitHub <noreply@github.com>2024-05-31 15:49:28 +0200
commitc6a8522c4c20078bb33157fc803373bf3532a02b (patch)
tree875182c134f6b525db33a29a506face0ca44b707
parent173deaa76ebaea2048e5f342013af6844979151f (diff)
parenta4f632d97bbb2e633bb2461688cbf3bcbb0d9e17 (diff)
downloadvyos-1x-c6a8522c4c20078bb33157fc803373bf3532a02b.tar.gz
vyos-1x-c6a8522c4c20078bb33157fc803373bf3532a02b.zip
Merge pull request #3568 from vyos/mergify/bp/sagitta/pr-3557
dns: T6422: allow multiple redundant NS records (backport #3557)
-rw-r--r--interface-definitions/service_dns_forwarding.xml.in1
-rwxr-xr-xsmoketest/scripts/cli/test_service_dns_forwarding.py10
-rwxr-xr-xsrc/conf_mode/service_dns_forwarding.py15
3 files changed, 25 insertions, 1 deletions
diff --git a/interface-definitions/service_dns_forwarding.xml.in b/interface-definitions/service_dns_forwarding.xml.in
index b52b4bda3..5667028b7 100644
--- a/interface-definitions/service_dns_forwarding.xml.in
+++ b/interface-definitions/service_dns_forwarding.xml.in
@@ -311,6 +311,7 @@
<constraint>
<regex>[-_a-zA-Z0-9.]{1,63}(?&lt;!\.)</regex>
</constraint>
+ <multi/>
</properties>
</leafNode>
#include <include/dns/time-to-live.xml.i>
diff --git a/smoketest/scripts/cli/test_service_dns_forwarding.py b/smoketest/scripts/cli/test_service_dns_forwarding.py
index 079c584ba..4db1d7495 100755
--- a/smoketest/scripts/cli/test_service_dns_forwarding.py
+++ b/smoketest/scripts/cli/test_service_dns_forwarding.py
@@ -291,5 +291,15 @@ class TestServicePowerDNS(VyOSUnitTestSHIM.TestCase):
tmp = get_config_value('edns-subnet-allow-list')
self.assertEqual(tmp, ','.join(options))
+ def test_multiple_ns_records(self):
+ test_zone = 'example.com'
+ self.cli_set(base_path + ['authoritative-domain', test_zone, 'records', 'ns', 'test', 'target', f'ns1.{test_zone}'])
+ self.cli_set(base_path + ['authoritative-domain', test_zone, 'records', 'ns', 'test', 'target', f'ns2.{test_zone}'])
+ self.cli_commit()
+ zone_config = read_file(f'{PDNS_REC_RUN_DIR}/zone.{test_zone}.conf')
+ self.assertRegex(zone_config, fr'test\s+\d+\s+NS\s+ns1\.{test_zone}\.')
+ self.assertRegex(zone_config, fr'test\s+\d+\s+NS\s+ns2\.{test_zone}\.')
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/src/conf_mode/service_dns_forwarding.py b/src/conf_mode/service_dns_forwarding.py
index 7e863073a..70686534f 100755
--- a/src/conf_mode/service_dns_forwarding.py
+++ b/src/conf_mode/service_dns_forwarding.py
@@ -102,7 +102,7 @@ def get_config(config=None):
'ttl': rdata['ttl'],
'value': address
})
- elif rtype in ['cname', 'ptr', 'ns']:
+ elif rtype in ['cname', 'ptr']:
if not 'target' in rdata:
dns['authoritative_zone_errors'].append(f'{subnode}.{node}: target is required')
continue
@@ -113,6 +113,19 @@ def get_config(config=None):
'ttl': rdata['ttl'],
'value': '{}.'.format(rdata['target'])
})
+ elif rtype == 'ns':
+ if not 'target' in rdata:
+ dns['authoritative_zone_errors'].append(f'{subnode}.{node}: at least one target is required')
+ continue
+
+ for target in rdata['target']:
+ zone['records'].append({
+ 'name': subnode,
+ 'type': rtype.upper(),
+ 'ttl': rdata['ttl'],
+ 'value': f'{target}.'
+ })
+
elif rtype == 'mx':
if not 'server' in rdata:
dns['authoritative_zone_errors'].append(f'{subnode}.{node}: at least one server is required')