Performing DNS Queries in Python

dnspython provides a detailed interface into DNS. In its simplest form, it’s possible to perform queries in only a couple of lines of code. Here’s a commented example: import dns.resolver #import the module myResolver = dns.resolver.Resolver() #create a new instance named ‘myResolver’ myAnswers = myResolver.query("", "A") #Lookup the ‘A’ record(s) for for rdata in myAnswers: #for each response print rdata #print the data The results in my case are: […]