import socket
import ipaddress


def forward_lookup(hostname):
    """Perform a forward lookup of a hostname."""
    ip_addresses = {}

    addresses = list(
        set(str(ip[4][0]) for ip in socket.getaddrinfo(hostname, None))
    )

    if addresses is None:
        return ip_addresses

    for address in addresses:
        if type(ipaddress.ip_address(address)) is ipaddress.IPv4Address:
            ip_addresses["ipv4"] = address
        if type(ipaddress.ip_address(address)) is ipaddress.IPv6Address:
            ip_addresses["ipv6"] = address

    return ip_addresses