4

This is not the same as How to multicast send to all network interfaces? which asks for a solution that would work in one program only, and requires source access - which I don't have.

I have a bunch of programs producing multicast traffic that I would like to see on my network, both wifi and ethernet, but I would also like them not to die from a "no route" when the network fails.

So what I really would like is to route all multicast traffic from a machine to all available interfaces, or to loopback if there are no interfaces up.

On Linux I can say:

sudo ifconfig lo multicast
sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev lo

But this means that people using eth0 or wlan0 can't get the multicasts.

Similarly I can say:

sudo ifconfig lo multicast
sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0

But then wlan0 won't get the multicast. Worse, my programs just crash with a "no route to [whatever multicast ip]" if all interfaces go down.

How do I route things so that they go to all adaptors, including loopback?

Community
  • 1
  • 1
Paul Foster
  • 45
  • 1
  • 1
  • 5

1 Answers1

6

You can use route to add mutlicast routes to multiple devices.

sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev wlan0

This was reflected in the routing table and allowed our services operating on the separate NICs to work.

However, its not clear to me that you should do this.

The reason I am not sure if the is "valid" is that I tried to port from using route which is apparently deprecated/obsolete to using "ip route", eg

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

However ip route won't let you add the second route. I have asked about how to properly use ip route without having to use explicit multicast group addresses, but if you are comfortable using route, you should be able to add the route to each device you need to use.

Community
  • 1
  • 1
gnac
  • 1,573
  • 15
  • 17
  • how do you make this persist through reboot? – tgabb Apr 17 '19 at 22:20
  • 1
    ip route does permit it, but it's with an arcane command which is not - in my opinion - well documented (see my answer to @gnac's reposted question [here](https://serverfault.com/a/1040786/191942). @tgabb - persisting this through reboot is dependent on your distribution - it is effectively a question of using the appropriate manager for your distribution to run this command after/when the interface is brought up (e.g. the `/etc/network/interfaces` file for debian) – Philip Adler Oct 31 '20 at 19:18