0

I am using dnspython library and not able to verify domain for gmail because of below error


import dns

domain = 'gmail.com'
answers = dns.resolver.query(domain,'MX')
for server in answers:
    print(server.target)


raise NXDOMAIN(qnames=qnames_to_try, responses=nxdomain_responses) NXDOMAIN: None of DNS query names exist:

1 Answers1

0

I faced the same issue and maybe for somebody my answer will be helpful.

You can try to use your current default DNS Server to query the DNS records. It's fixed the issue for me.

Open cmd.exe and run commands below:

ipconfig /all | findstr /R "DNS\ Servers"

C:\>ipconfig /all | findstr /R "DNS\ Servers"
   DNS Servers . . . . . . . . . . . : 223.121.180.100
   DNS Servers . . . . . . . . . . . : 223.121.180.101

Take first DNS Server IP address and set it as a nameserver for the resolver, as an additional nameservers you can set one from Google and one from Cloudflare.

my_resolver = dns.resolver.Resolver(configure=False)
my_resolver.nameservers = ['223.121.180.100', '8.8.8.8', '1.1.1.1']
answer = my_resolver.query('google.com', 'A')
Aleksandr Podkutin
  • 2,532
  • 1
  • 20
  • 31