]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Extended the example to include one with RD=0 719/head
authorPaul Hoffman <phoffman@proper.com>
Tue, 2 Nov 2021 16:43:10 +0000 (09:43 -0700)
committerPaul Hoffman <phoffman@proper.com>
Tue, 2 Nov 2021 16:43:10 +0000 (09:43 -0700)
examples/query_specific.py

index f0121fb3a106bdc1e673a38ac46f1675e609e377..fcbfc241b87004928ceeb73aaf1e3d73dd859290 100644 (file)
@@ -35,3 +35,13 @@ answer = resolver.resolve('amazon.com', 'NS')
 print('The nameservers are:')
 for rr in answer:
     print(rr.target)
+
+# Sending a query with the RD flag set to 0
+#   This sends a query with RD=0 for the root SOA RRset to the IP address for l.root-servers.net
+
+q = dns.message.make_query('.', dns.rdatatype.SOA)
+# Set the RD flag to 0
+q.flags &= ~dns.flags.RD
+r = dns.query.udp(q, '199.7.83.42')
+print('\nThe flags in the response are {}'.format(dns.flags.to_text(r.flags)))
+print('The SOA in the response is "{}"'.format((r.answer)[0][0]))