title: Use ip route add to add multicast routes to multiple devices
body: <p>TLDR: Is there a way to use "ip route" to add multicast routes for multiple NICs? </p>
  
  <p>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.</p>
  
  <p>We are currently using a bash script (Linux kernel 3.14.39) to set multicast routes on the two network interfaces using route, eg </p>
  
  <pre><code>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
  </code></pre>
  
  <p>and verified via route -n</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I recently read that route was deprecated/obsolete and that we should be using ip route instead, eg </p>
  
  <pre><code>ip route add 224.0.0.0/4 dev eth0
  ip route add 224.0.0.0/4 dev eth1
  </code></pre>
  
  <p>Unfortunately, the second call fails with "RTNETLINK answers: File exists" and of course the second route doesn't show up after these calls. </p>
  
  <p>Is there a way to use ip route to add multicast routes to multiple NICs? </p>
  
  <p>I can use /8 as a netmask? eg </p>
  
  <pre><code>ip route add 233.0.0.0/8 dev eth0
  </code></pre>
  
  <p>and</p>
  
  <pre><code>ip route add 239.0.0.0/8 dev eth1
  </code></pre>
  
  <p>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.</p>