By default Linux ignores Broadcast and Multicast ICMP messages. That's why you need to enable it first:
sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=0
To join any mutlicast address (e.g. 224.10.10.10/24
) just add it to your active interface (e.g. eth0
) and append the keyword autojoin
at the end:
ip addr add 224.10.10.10/24 dev eth0 autojoin
Now you can verify the join:
ip -f inet maddr show dev eth0
Finally to test the Multicast communication, ping to the chosen IP address from another host:
ping 224.10.10.10
You should now get an answer from your Multicast enabled host. That's it.
The Linux Kernel normally uses IGMP version 3 to join Multicast groups. If you would rather use IGMP version 2, just change it via the command down here:
echo "2" > /proc/sys/net/ipv4/conf/eth0/force_igmp_version
In order to get the commands above here working inside a Docker container, it must be started with the Linux capability NET_ADMIN
:
docker run --rm -it --cap-add NET_ADMIN alpine /bin/sh
Fun fact: GNS3 starts all containers with all Linux capabilities added and in priviledged mode.
https://unix.stackexchange.com/questions/140384/creating-multicast-join-for-tcpdump-captures
Here is the command line I am using to view traffic:
tcpdump -nnXs 0 -i eth1 udp port 22001 and dst 233.54.12.234
This works fine so long as I have a multicast subscription to that group already established. For example, if I run this in another console:
mdump 233.54.12.234 22001 10.13.252.51
tcpdump will see packets. If mdump is not running, tcpdump sees nothing.