I am using dns.resolver from dnspython.
Is it possible to set the IP address of the server to use for queries ?
I am using dns.resolver from dnspython.
Is it possible to set the IP address of the server to use for queries ?
Since there's no example of how to do this with dnspython in 2021, I thought I'd post one:
import dns.resolver
resolver = dns.resolver.Resolver()
resolver.nameservers = ['8.8.8.8'] # using google DNS
result = resolver.resolve('google.com', 'NS')
nameservers = [ns.to_text() for ns in result]
Output:
['ns1.google.com.', 'ns3.google.com.', 'ns2.google.com.', 'ns4.google.com.']