Multicast routing on Mac OS - belaban/JGroups GitHub Wiki

Multicast routing on Mac OS X is a bit different from Linux. For some reason, a node bound to 127.0.0.1 (lo0) cannot use a multicast route via en0.

When bind_addr (in UDP) is set to 127.0.0.1, then multicasting might fail with the following error message:

[WARN] UDP: JGRP000034: Host-A: failure sending message to /224.0.0.251: java.io.IOException: Can't assign requested address (sendto failed)

To accomplish this, 2 multicast routes have to be added:

# Adds a multicast route for 224.0.0.1-231.255.255.254
sudo route add -net 224.0.0.0/5 127.0.0.1

# Adds a multicast route for 232.0.0.1-239.255.255.254
sudo route add -net 232.0.0.0/5 192.168.1.3

When binding to 192.168.1.3, a multicast address (UDP.mcast_addr) from then second range has to be used and when binding to 127.0.0.1, an address from the first range should be used.

The following combination will now work:

<UDP bind_addr="127.0.0.1" mcast_addr="228.8.8.8".../>

or

<UDP bind_addr="192.168.1.3" mcast_addr="232.2.2.2".../>

For some reasons, when forcing the use of an IPv4 stack only (using -Djava.net.preferIPv4Stack=true), this issue doesn’t occur. However, when running without this system property, then the (default) IPv6 stack used issues this error.

According to reports, this problem doesn’t occur on Linux systems (I have yet to confirm this).

See [1] for details.

[1] https://issues.jboss.org/browse/JGRP-1808

⚠️ **GitHub.com Fallback** ⚠️