Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse DNS lookup in Python

Tags:

python

ipv6

If I have an IP address like 2001:4860:4860::8888

How can I get the fully qualified domain in the format foo.ip6.arpa ?

EDIT: Both the solutions so far give me google-public-dns-a.google.com - maybe Reverse DNS was the wrong name. For this I'd expect the output to be something like 8.8.8.8.0...etc.ip6.arpa

like image 827
Ivy Avatar asked Aug 10 '12 11:08

Ivy


1 Answers

using dnspython.

from dns import resolver,reversename
addr=reversename.from_address("2001:4860:4860::8888")
str(resolver.query(addr,"PTR")[0])
like image 151
Vinayak Kolagi Avatar answered Nov 11 '22 09:11

Vinayak Kolagi