import socket
s=socket.socket(socket.AF_INET, socket.SOC)
s.gethostname()[0]


from dns import reversename, resolver

rev_name = reversename.from_address('172.16.31.10')
reversed_dns = str(resolver.query(rev_name,"PTR")[0])
# 'crawl-203-208-60-1.googlebot.com.'

import socket

reversed_dns = socket.gethostbyaddr('172.16.31.10')
# ('crawl-203-208-60-1.googlebot.com', ['192.168.3.11.in-addr.arpa'], ['172.16.58.3'])
reversed_dns[0]
# 'crawl-203-208-60-1.googlebot.com'