diff --git a/seed/nsd/dictionaries/20_nsd.xml b/seed/nsd/dictionaries/20_nsd.xml index 65dfcdc5..8fc663d7 100644 --- a/seed/nsd/dictionaries/20_nsd.xml +++ b/seed/nsd/dictionaries/20_nsd.xml @@ -93,6 +93,7 @@ /etc/nsd/ nsd_reverse_name reverse + True True nsd_reverse_filenames diff --git a/seed/nsd/funcs/funcs.py b/seed/nsd/funcs/funcs.py index 31582bb0..1cf4c33d 100644 --- a/seed/nsd/funcs/funcs.py +++ b/seed/nsd/funcs/funcs.py @@ -44,8 +44,8 @@ def get_reverse_name(network: str) -> str: if not network: return network_obj = ip_network(network) - if network_obj.prefixlen != 24: - raise ValueError('only netmask "255.255.255.0" is supported for DNS reverse name') + if network_obj.prefixlen < 24: + raise ValueError('only netmask greater than 24 is supported for DNS reverse name') o1, o2, o3, o4 = network.split('.') return f'{o3}.{o2}.{o1}.in-addr.arpa.' diff --git a/seed/nsd/templates/nsd.reverse b/seed/nsd/templates/nsd.reverse index 7ac9f94c..077d41e4 100644 --- a/seed/nsd/templates/nsd.reverse +++ b/seed/nsd/templates/nsd.reverse @@ -1,5 +1,5 @@ %set %%name = None -%set %%network = %%ip_network(%%nsd_reverse_network[%%rougail_index]) +%set %%network = %%str(%%nsd_reverse_network[%%rougail_index]).rsplit('.', 1)[0] %for %%zone in %%nsd_zones %set %%suffix = %%normalize_family(%%zone) %set %%hostnames = %%nsd["nsd_zone_" + %%suffix]["hostname_" + %%suffix]["hostname_" + %%suffix] @@ -23,7 +23,7 @@ $TTL 1800 IN NS %%domain_name_eth0. %end if %set %%ip = %%hostname['ip_' + %%suffix] - %if %%ip_address(%%ip) in %%network + %if %%ip.startswith(%%network) %set %%id = %%ip.rsplit('.', 1)[1] %%id PTR %%hostname.%%{zone}. %end if diff --git a/seed/nsd/templates/risotto.conf b/seed/nsd/templates/risotto.conf index 261116a6..12d81a73 100644 --- a/seed/nsd/templates/risotto.conf +++ b/seed/nsd/templates/risotto.conf @@ -17,9 +17,14 @@ zone: name: "%%zone" zonefile: "%%{zone}.zone.signed" %end for +%set %%reversed = [] %for %%reverse in %%nsd_reverse_network + %if %%reverse.nsd_reverse_name in %%reversed + %continue + %end if +%%reversed.append(%%reverse.nsd_reverse_name)%slurp zone: name: "%%reverse.nsd_reverse_name" - zonefile: "%%{reverse.nsd_reverse_name}reverse.signed" + zonefile: "%%{reverse.nsd_reverse_name.replace('/', '-')}reverse.signed" %end for