import socket


def dnsname(ip):
    """Returns the DNS hostname of the provided IP address if it's in DNS (PTR record)"""
    try:
        return socket.gethostbyaddr(ip)[0]
    except:
        return 'null'