Skip to content

Commit

Permalink
Merge pull request #3568 from vyos/mergify/bp/sagitta/pr-3557
Browse files Browse the repository at this point in the history
dns: T6422: allow multiple redundant NS records (backport #3557)
  • Loading branch information
c-po authored May 31, 2024
2 parents 173deaa + a4f632d commit c6a8522
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions interface-definitions/service_dns_forwarding.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 10 additions & 0 deletions smoketest/scripts/cli/test_service_dns_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,15 @@ def test_edns_subnet_allow_list(self):
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)
15 changes: 14 additions & 1 deletion src/conf_mode/service_dns_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit c6a8522

Please sign in to comment.