mcastsock.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP, socket.
    inet_aton(mcast_addr) + socket.inet_aton(if_ip))
mcastsock.bind((mcast_addr, port))
Choosing multicast network interface in Python