1

I want to create a multicast group with 3 computers then ping them all, how is it done in the Linux CLI?

0

1 Answer 1

1

You can use the socat command to achieve this, as described in the documentation:

Example 3: Multicast peers

It is possible to combine multicast sender and receiver in one socat address. This allows to start processes on different hosts on the local network that will communicate symmetrically, so each process can send messages that are received by all the other ones.

socat STDIO UDP4-DATAGRAM:224.1.0.1:6666,bind=:6666,range=192.168.10.0/24,ip-add-membership=224.1.0.1:192.168.10.2

This command is valid for host 192.168.10.2; adapt this address to the particular interface addresses of the hosts.

So for a simpler example not caring about source validation nor choosing an interface (thus following the default route for IPv4: a router would probably require additional options to use the LAN side), running this on each system (even multiple times with reuseaddr: multicast also duplicates data locally accordingly) in the same LAN achieves communication:

socat - UDP4-DATAGRAM:239.255.255.245:6666,bind=:6666,ip-add-membership=239.255.255.245:0.0.0.0,reuseaddr

Of course multicast isn't routed by standard routers. If this has to be scaled across multiple LANs, this require setting up (a) multicast router(s) and would be beyond the scope of this answer.

Simple tools supporting simply IPv6 are more difficult to find. The example above transformed with an IPv6 address requires passing raw setsockopt values to achieve the same effect. With address ff05::db8:1:2 on first system's interface (after lo), thus with index 2 (system's default can easily be wrong with IPv6), that would be the less readable command:

socat - 'UDP6-DATAGRAM:[ff05::db8:1:2]:6666,bind=:6666,setsockopt=41:17:i2,setsockopt=41:20:xff0500000000000000000db800010002i2,reuseaddr'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .