import socket


def resolve_fqdn_ip(fqdn):
    """Attempt to retrieve the IPv4 or IPv6 address to a given hostname."""
    try:
        return socket.inet_ntop(socket.AF_INET, socket.inet_pton(socket.AF_INET, socket.gethostbyname(fqdn)))
    except Exception:
        # Probably using ipv6
        pass
    try:
        return socket.inet_ntop(socket.AF_INET6, socket.inet_pton(socket.AF_INET6, socket.getaddrinfo(fqdn, None, socket.AF_INET6)[0][4][0]))
    except Exception:
        return ''