import socket


def _get_local_ip(ip: str, port: int = 80) -> str:
    """
    For a given IP, return the local IP that can access it

    Args:
        ip (str): Remote IP
        port (int, optional): Remote port. Defaults to `80`

    Returns:
        str: The local IP that can access the given remote IP
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect((ip, port))
    local_ip = s.getsockname()[0]
    s.close()
    return local_ip