import dns.query import dns.zone def get_dns_serial(zone_name, nameserver): try: # Query the nameserver for the zone response = dns.query.tcp(dns.message.make_query(zone_name, dns.rdatatype.SOA), nameserver) # Parse the response answer = dns.zone.from_text(response.answer[0].to_text(), zone_name) serial = answer.get_rdataset(zone_name, dns.rdatatype.SOA)[0].serial return serial except Exception as e: print(f"Error: {e}") return None # Example usage zone_name = "0x5e.eu" nameserver = "ns1.it53.nl" # Use the desired nameserver's IP address serial = get_dns_serial(zone_name, nameserver) if serial: print(f"The DNS serial for {zone_name} is {serial}") else: print(f"Failed to fetch DNS serial for {zone_name}")