Add week 7 materials
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Trace the real private hierarchy root-dns -> tld-dns -> auth."""
|
||||
import subprocess
|
||||
|
||||
|
||||
def dig(*args):
|
||||
command = ["dig", "-r", *args, "+time=2", "+tries=1"]
|
||||
print("\n$ " + " ".join(command), flush=True)
|
||||
result = subprocess.run(command, capture_output=True, text=True, timeout=20)
|
||||
print(result.stdout, flush=True)
|
||||
if result.returncode:
|
||||
raise RuntimeError(result.stderr or result.stdout)
|
||||
return result.stdout
|
||||
|
||||
|
||||
def main():
|
||||
print("Private hierarchy: root-dns (.) -> tld-dns (test.) -> auth (lab.test.)")
|
||||
trace = dig("@root-dns", "+trace", "+nodnssec", "orders.lab.test", "A")
|
||||
assert "192.0.2." in trace and "ns.test." in trace and "ns.lab.test." in trace
|
||||
referral = dig("@root-dns", "orders.lab.test", "A", "+norecurse")
|
||||
assert "ANSWER: 0" in referral and "ns.test." in referral
|
||||
tld = dig("@tld-dns", "orders.lab.test", "A", "+norecurse")
|
||||
assert "ANSWER: 0" in tld and "ns.lab.test." in tld
|
||||
final = dig("@auth", "orders.lab.test", "A", "+norecurse")
|
||||
assert "192.0.2." in final and "flags: qr aa" in final
|
||||
print("PASS: real root/TLD referrals and final authoritative answer in the private hierarchy")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user