def joinMcast(mcast_addr, port, if_ip):
    """
    Returns a live multicast socket
    mcast_addr is a dotted string format of the multicast group
    port is an integer of the UDP port you want to receive
    if_ip is a dotted string format of the interface you will use
    """
mcastsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
mcastsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
mcastsock.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP, socket.
    inet_aton(mcast_addr) + socket.inet_aton(if_ip))
Выбор многоадресного сетевого интерфейса в Python