9

There is quite a few examples to RECEIVE multicast messages with a spcific network interface (NIC, e.g. eth0, 127.0.0.1 etc). However, there is few discussion/examples about how to SEND multicast (UDP) messages to a specific interface, e.g. local loop (127.0.0.1) instead of eth0 by default.

Background: RedHat Linux, Python, 224.1.1.1 5005

Python Code example in Multicast in Python

A similar discuss for IPv6 How to send multicast packets via a specfic interface in Linux

A similar discuss for Windows How to Multicast (send) to first NIC?

Thanks in advance.

1 Answer 1

8

The question that you've linked How to Multicast (send) to first NIC? mentions that you could use IP_MULTICAST_IF:

sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(addr))
Sign up to request clarification or add additional context in comments.

3 Comments

Don't forget to increase TTL
@e271p314: I don't remember what it is about but the code example that is linked in the question appears to handle TTL already (since 2009). My answer sets a single option i.e., it only answers the question in the title.
First of all, thanks a lot, your answer is correct. when I tried it I saw I didn't get the multicast and was breaking my head to understand what is the issue. My TTL was configured to 2 because I copy pasted the code. After some time I realized from this link That I need to "Increase to reach other networks" So I just though that if might be usful to other which came to your answer get this tip too :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.