Skip to content

Instantly share code, notes, and snippets.

@ykhrustalev
Created March 27, 2013 09:26
Show Gist options
  • Save ykhrustalev/5252944 to your computer and use it in GitHub Desktop.
Save ykhrustalev/5252944 to your computer and use it in GitHub Desktop.
# source http://small-code.blogspot.ru/2008/05/nslookup-in-python.html
from socket import gethostbyaddr
def nslooky(ip):
try:
output = gethostbyaddr(ip)
return output[0]
except:
output = "not found"
return output
your_ip = request.META.get('REMOTE_ADDR')
# above is Django module object
your_name = nslooky(your_ip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment