import socket


def _get_serve_ip(target_ip, target_port=80):
    """ Find ip address of network interface used to communicate with target
    
    target-ip -- ip address of target
    return -- ip address of interface connected to target
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect((target_ip, target_port))
    my_ip = s.getsockname()[0]
    s.close()
    return my_ip