From ed5972659943d237301d94fb092399e7fcccb2de Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 14 Apr 2021 20:15:56 +0800 Subject: [PATCH] add ds record, fix rfc2317 script --- dns/db.10.127 | 2 ++ dns/db.fd10.127 | 2 ++ dns/neonetwork | 3 +++ dns/rfc2317.toml | 9 ++++++--- scripts/dns-generator.py | 10 ++++++---- scripts/rfc2317.py | 11 +++++++---- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/dns/db.10.127 b/dns/db.10.127 index 08a6cc1..8623bb4 100644 --- a/dns/db.10.127 +++ b/dns/db.10.127 @@ -58,6 +58,8 @@ $TTL 3600 9 IN NS ns1.jerry.neo. 9 IN NS ns2.jerry.neo. +9 IN NS ns3.jerry.neo. +9 IN DS 35017 13 2 31AA09841AF1F44753F0733ECD32A19E45368AAD4136B6AC75A3DCD257EFAA5C 10 IN NS ns-anycast.lantian.neo. 10 IN NS ns1.lantian.neo. diff --git a/dns/db.fd10.127 b/dns/db.fd10.127 index dc23d8e..65fe549 100644 --- a/dns/db.fd10.127 +++ b/dns/db.fd10.127 @@ -20,6 +20,8 @@ $TTL 3600 ; DELEGATED ZONES 3.5.0.0 IN NS ns1.jerry.neo. 3.5.0.0 IN NS ns2.jerry.neo. +3.5.0.0 IN NS ns3.jerry.neo. +3.5.0.0 IN DS 53626 13 2 F7F6AFCCA1CEC26E2A6EE9FAC9E11975260F00B8DC287D0B0FF428F775C62C5D 0.1.0.0 IN NS ns-anycast.lantian.neo. 0.1.0.0 IN NS ns1.lantian.neo. diff --git a/dns/neonetwork b/dns/neonetwork index 572ecd2..1cd9ab7 100644 --- a/dns/neonetwork +++ b/dns/neonetwork @@ -36,10 +36,13 @@ edwardp IN AAAA fd10:127:2f2f:: ; DELEGATED ZONES jerry IN NS ns1.jerry jerry IN NS ns2.jerry +jerry IN DS 18792 13 2 2F335456EEE70FC4833886E5EEDC28E7195E90E2A337860B3E805D5EB9F3A804 ns1.jerry IN A 10.127.8.193 ns1.jerry IN AAAA fd10:127:53::1 ns2.jerry IN A 10.127.8.216 ns2.jerry IN AAAA fd10:127:53:100::1 +ns3.jerry IN A 10.127.8.208 +ns3.jerry IN AAAA fd10:127:53:200::1 kp IN NS ns1.kp ns1.kp IN A 10.127.39.1 diff --git a/dns/rfc2317.toml b/dns/rfc2317.toml index c9aa4e3..f21da42 100644 --- a/dns/rfc2317.toml +++ b/dns/rfc2317.toml @@ -1,8 +1,11 @@ ["10.127.8.64/26"] -ns = ["ns1.jerry.neo.", "ns2.jerry.neo."] +NS = ["ns1.jerry.neo.", "ns2.jerry.neo.", "ns3.jerry.neo."] +DS = ["24982 13 2 463EAE9D8248179806321A2ED3F05377234FD13DF0C2F20428C3B148F9C31B3D"] +TTL = -1 ["10.127.8.192/26"] -ns = ["ns1.jerry.neo.", "ns2.jerry.neo."] +NS = ["ns1.jerry.neo.", "ns2.jerry.neo.", "ns3.jerry.neo."] +DS = ["12536 13 2 A2AEEFCDB5F0BB6C4AC075EF1034C5635AEFE5A2DA9E7FF7D8BBE53B5E61E8E3"] ["10.127.8.160/27"] -ns = ["ns1.staph.neo."] +NS = ["ns1.staph.neo."] diff --git a/scripts/dns-generator.py b/scripts/dns-generator.py index fb468b8..444fc4e 100755 --- a/scripts/dns-generator.py +++ b/scripts/dns-generator.py @@ -11,15 +11,17 @@ RFC2317_FILE = Path("dns", "rfc2317.toml") def iter_rfc2317_entry(): entries = toml.loads(RFC2317_FILE.read_text()) for (route, attributes) in entries.items(): - ns = attributes.get('ns') - yield(route, ns) + ns = attributes.get('NS') + ds = attributes.get('DS', list()) + ttl = attributes.get('TTL', -1) + yield(route, ns, ds, ttl) def main(): orignal = RESOLVE_FILE.read_text() records = [orignal, "; AUTOGENERATED"] records.extend(("", "; rfc2317")) - for route, ns in iter_rfc2317_entry(): - records.extend(gen_reverse_pointers(route, ns)) + for route, ns, ds, ttl in iter_rfc2317_entry(): + records.extend(gen_reverse_pointers(route, ns, ds, ttl)) records.append("") RESOLVE_FILE.write_text("\n".join(records)) diff --git a/scripts/rfc2317.py b/scripts/rfc2317.py index bf3b6dd..d9badff 100755 --- a/scripts/rfc2317.py +++ b/scripts/rfc2317.py @@ -8,19 +8,22 @@ def truncate(rev: str) -> str: rev = rev[:-len(ZONE)] return rev -def gen_reverse_pointers(network: str, ns: list) -> list: +def gen_reverse_pointers(network: str, ns: list, ds: list = [], ttl: int = -1) -> list: + ttl = f"{ttl} " if 900 <= ttl <= 86400 else "" buf = list() net = ipaddress.IPv4Network(network, strict=True) assert net.prefixlen > 24 netrev = truncate(net.reverse_pointer) for _ns in ns: - buf.append(f"{netrev:<10s} IN NS {_ns}") + buf.append(f"{netrev} {ttl}IN NS {_ns}") + for _ds in ds: + buf.append(f"{netrev} {ttl}IN DS {_ds}") for addr in net: cnamefr = truncate(addr.reverse_pointer) cnameto = f"{int.from_bytes(addr.packed, byteorder='big', signed=False) & 0xff}.{netrev}" - buf.append(f"{cnamefr:<10s} IN CNAME {cnameto}") + buf.append(f"{cnamefr} {ttl}IN CNAME {cnameto}") return buf if __name__ == "__main__": - print("\n".join(gen_reverse_pointers('10.127.8.64/26', ['ns1.jerry.neo.']))) + print("\n".join(gen_reverse_pointers('10.127.8.64/26', ['ns1.jerry.neo.'], ['18792 13 2 2F335456EEE70FC4833886E5EEDC28E7195E90E2A337860B3E805D5EB9F3A804'], ttl=1500)))