Difficulty using Python's socket.gethostbyaddr()
I am trying to reverse dns a list of IPs using socket.gethostbyaddr() in python, which returns 'Unknown Host' for some values, but using dig for the same ip returns the Hostname. Also, dig seems to be significantly faster than using python module, is there any specific reasons for that? import socket # This returns 'Unknown Host' name, alias, addresslist = socket.gethostbyaddr('114.143.51.197') I'm sorry, but you are mistaken. 114.143.51.197 does not have a PTR record... therefore socket.gethostbyaddr() should throw an error... you certainly need a try / except clause that traps for socket