Skip to content

Instantly share code, notes, and snippets.

@PhilipSchmid
Last active March 18, 2024 14:36
Show Gist options
  • Save PhilipSchmid/2597c23c68f21d938779aa92683d30b2 to your computer and use it in GitHub Desktop.
Save PhilipSchmid/2597c23c68f21d938779aa92683d30b2 to your computer and use it in GitHub Desktop.
Testing Multicast Traffic on Linux

Testing Multicast Traffic on Linux

Prerequisites

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

Join and Test Multicast Traffic

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.

Change IGMP Version

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

Multicast Group Join Inside Docker Container

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.

@Surya-ARBY
Copy link

Be sure to start a multicast ping from another host and the one from which you've bound to the multicast address. Also be sure to issue ping -t 16 224.10.10.10 otherwise all packets will leave with a TTL=1.

@Pengtai9928
Copy link

still seeing "connect: Invalid argument" after adding "-t 16" argument to ping

@Surya-ARBY
Copy link

is multicast correctly enabled on your system ?

@Pengtai9928
Copy link

do you mean set "sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=0"?

@Surya-ARBY
Copy link

yes, the command given above works well on my ubuntu.

@Pengtai9928
Copy link

I see. Maybe there is some issue on my end. Thanks Surya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment