import socket


def _get_ip(remote):
    """Get the local IP of a connection to the to a remote host."""
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        sock.connect((remote, 1883))
        address = sock.getsockname()[0]
    finally:
        sock.close()

    return list(map(int, address.split(".")))