From 86c7a00b5b7f45ca22906019b7de2e87ab354eb7 Mon Sep 17 00:00:00 2001 From: lare Date: Sun, 12 Feb 2023 00:26:37 +0100 Subject: [PATCH] add support for /16,/8 + show critical error if 'dnspython' isn't installed --- validate-my-dns.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/validate-my-dns.py b/validate-my-dns.py index 7ef5b8a..723c2a5 100644 --- a/validate-my-dns.py +++ b/validate-my-dns.py @@ -8,12 +8,18 @@ import os import subprocess import json -import dns.name -import dns.query -import dns.dnssec -import dns.message -import dns.resolver -import dns.rdatatype +try: + import dns.name + import dns.query + import dns.dnssec + import dns.message + import dns.resolver + import dns.rdatatype +except ImportError: + print() + print("CRITICAL: this script requires the 'dnspython' libary, please install it using `python3 -m pip install dnspython`") + print() + exit(1) # import errors so they could be try/catched import dns.exception @@ -79,11 +85,15 @@ def get_domain_by_mntner(mntner): line = line[20:] _domain_name = ".".join( line.split(".")[::-1]) + ".in-addr.arpa" - if int(line.split("/")[1]) ==24: - _domain_name.replace("/24", "") + if int(line.split("/")[1]) == 24: + _domain_name = _domain_name.replace("0/24.", "") + elif int(line.split("/")[1]) == 16: + _domain_name = _domain_name.replace("0/16.0.", "") + elif int(line.split("/")[1]) == 8: + _domain_name = _domain_name.replace("0/8.0.0.", "") elif int(line.split("/")[1]) <=24: # TODO: implement creation of multiple zones for every /24 within - pass + print(f"WARN: currently only ipv4 subnets with length >=24 or 16 or 8 are possible to be checked: relavent inetnum {line}") elif line.startswith("nserver"): nserver = line[20:].split(" ") # handle edge case where