DNS/実装/python/dnslib/example/jp_queryについて、ここに記述してください。 {{{#!python # -*- coding: utf-8 -*- """ DNS Client - DiG-like CLI utility. Usage: python -m dnslib.client [options|--help] """ from __future__ import print_function #import binascii,code,pprint,sys from dnslib.dns import DNSRecord,DNSHeader,DNSQuestion,DNSError,QTYPE,EDNS0 from dnslib.digparser import DigParser if __name__ == '__main__': # import sys,time try: domain = 'qmail.jp' q = DNSRecord(q=DNSQuestion(domain, getattr(QTYPE,'NS'))) address= '203.119.1.1' # a.dns.jp a_pkt = q.send(address, 53, tcp=False) a = DNSRecord.parse(a_pkt) if a.header.tc : # Truncated - retry in TCP mode a_pkt = q.send(address,port,tcp=True) a = DNSRecord.parse(a_pkt) # NXDOMAIN rcode if a.header.rcode != 0 : # ['NOERROR', 'NXDOMAIN', 'SERVFAIL', 'REFUSED']: print (domain, a.header.rcode) # print(";; Got answer:"); print(a.toZone()) else: for r in a.auth: print (domain, '@'+str(r.rdata)[ :-1]) print() except DNSError as e: p.error(e) #The default text representation of the DNSRecord is in zone file format: }}}