Use ip route add to add multicast routes to multiple devices
Asked Answered
C

0

5

TLDR: Is there a way to use "ip route" to add multicast routes for multiple NICs?

We have software that joins two sockets bound to different ip addresses on separate NICS to two separate multicast groups, eg socket 1 is bound to 192.168.0.2 and joined to multicast group 233.255.10.1 while socket 2 is bound to 10.57.31.2 and joined to multicast group 239.255.100.1.

We are currently using a bash script (Linux kernel 3.14.39) to set multicast routes on the two network interfaces using route, eg

route add -net 224.0.0.0 netmask 240.0.0.0 eth0
route add -net 224.0.0.0 netmask 240.0.0.0 eth1

and verified via route -n

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
224.0.0.0       0.0.0.0         240.0.0.0       U     0      0        0 eth0
224.0.0.0       0.0.0.0         240.0.0.0       U     0      0        0 eth1

I recently read that route was deprecated/obsolete and that we should be using ip route instead, eg

ip route add 224.0.0.0/4 dev eth0
ip route add 224.0.0.0/4 dev eth1

Unfortunately, the second call fails with "RTNETLINK answers: File exists" and of course the second route doesn't show up after these calls.

Is there a way to use ip route to add multicast routes to multiple NICs?

I can use /8 as a netmask? eg

ip route add 233.0.0.0/8 dev eth0

and

ip route add 239.0.0.0/8 dev eth1

but this is problematic as the script that does this is not aware of what multicast address is associated with which device and its not always guaranteed to be the same depending on system configuration. Using my first example of route add makes this a non issue.

Categorical answered 3/11, 2016 at 0:18 Comment(3)
SO is for programming questions. Questions about using Unix belong on unix.SE or SuperUser.com.Playreader
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask.Cthrine
For journeyers like me who were brought here, this was reposted in the serverfault stack exchange .Kephart

© 2022 - 2024 — McMap. All rights reserved.