Created
November 6, 2014 20:43
-
-
Save mjseeley/af0a75ac8f7db8a15b4e to your computer and use it in GitHub Desktop.
def get_rdns(ip)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
# Function/arguments: get_rdns(ip) | |
# Description: Perform a reverse DNS query for the passed-in IP address. | |
# Returns: String: the reverse DNS name, or ''. | |
def get_rdns(ip): | |
try: | |
result = socket.gethostbyaddr(ip)[0] | |
except socket.herror: | |
# print 'Unable to get rDNS for', ip | |
result = ip | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment