Linux Multicast Interface Selection

I work with a cluster of 40 nodes running Debian 4. Each node starts a daemon that sits and listens on the IP address of the multicast.

I wrote some client software to send multicast over a local network with a client computer on the same switch as the cluster, so that every node in the cluster will receive a packet and respond.

It works fine, except when I run the client software on a computer with LAN and WAN interfaces. If there is a WAN interface, multicast does not work. Thus, I believe that multicasting was incorrectly passing through the WAN interface (eth0), and not on the LAN (eth1.) So, I use the socket parameter SO_BINDTODEVICE to force the multicast socket to use eth1, and that's fine.

But I thought the kernel routing table should determine that LAN (eth1) is obviously a cheaper destination for multicast. Is there any reason why I should explicitly force the socket to use eth1? And is there any way (possibly calling ioctl) that I can get the application to automatically detect if a particular interface is a local or global network?

+3
source share
2 answers

Unless you are explicitly tied to an interface, I believe that Linux uses the unicast interface as the default route for sending multicast.

Linux needs a multicast route, if it does not exist, you will get an EHOSTUNREACH or ENETUNREACH error. The project is a scope field in IPv6 addresses, but not all platforms properly support it. As dameiss notes, the Stevens Unix Network Programming book covers these details, and you can view most of the multicast chapter through Google Books for free.

+6
source

, , Linux . , - WAN.

"Unix Network Programming, 1", 17 ( , ), , .

+4

Source: https://habr.com/ru/post/1707017/


All Articles