feat: add diagnostic and management scripts for DNS, NPM, and cluster infrastructure

This commit is contained in:
2026-11-06 19:08:19 -05:00
parent 8e1c5f1e66
commit d5c2f6eae5
19 changed files with 559 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
import socket
import sys
def make_query(name):
import random
txid = random.randint(1, 65535)
header = txid.to_bytes(2, 'big') + (0x0100).to_bytes(2, 'big') + (1).to_bytes(2, 'big') + b'\x00\x00\x00\x00\x00\x00'
qname = b''.join([bytes([len(p)]) + p.encode('ascii') for p in name.split('.')]) + b'\x00'
return header + qname + (1).to_bytes(2, 'big') + (1).to_bytes(2, 'big')
def query_ip(server, domain):
packet = make_query(domain)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(2.0)
try:
s.sendto(packet, (server, 53))
data, _ = s.recvfrom(1024)
# Parse answer IP (last 4 bytes of first A record)
if len(data) >= 16:
ip = f"{data[-4]}.{data[-3]}.{data[-2]}.{data[-1]}"
return ip
except Exception as e:
return str(e)
finally:
s.close()
for server in ["140.44.4.36", "140.44.4.65"]:
for dom in ["pihole1.snarfnet.net", "pihole2.snarfnet.net", "dns1.snarfnet.net", "dns2.snarfnet.net", "ns1.snarfnet.net", "ns2.snarfnet.net"]:
ip = query_ip(server, dom)
print(f"[{server}] {dom:<25} -> {ip}")