In this tutorial, we explore ways to check whether IP multicast is available and enabled in Linux. First, we verify whether our kernel has the ability to use multicast. Next, we look at different tools we can use to confirm the status of the function on our network interfaces. Finally, we discuss a couple of other methods to get data about multicast from our system.
We tested the code in this tutorial on Debian 11 (Bullseye) with GNU Bash 5.1.4. It should work in most POSIX-compliant environments.
2. Kernel Multicast
Naturally, the first step is to verify our kernel supports multicast at all. However, we won’t be able to check the already-compiled kernel directly.
# apt-get source linux [...]
After getting the sources, we can use grep to look for CONFIG_IP_MULTICAST in the main kernel configuration file /usr/src/linux/.config:
$ grep --files-with-matches 'CONFIG_IP_MULTICAST' /usr/src/linux/.config /usr/src/linux/.config
Using the –files-with-matches flag, we get our file’s path back only if it matches. In this case, this also means that the kernel supports multicasting.
Now, let’s see how to confirm our network interfaces have it enabled.
3. Check and Toggle Multicast with ifconfig
In fact, we can employ ifconfig to check the multicast support and configuration:
$ ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 [...] lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 [...]
Consequently, we see a single interface outside of lo loopback. Notably, eth0 has multicast enabled above, as confirmed by the MULTICAST keyword in the comma-separated list within angle brackets.
Appending an interface name to the end of the command shows the results only for that interface.
Of course, we can also toggle multicast with ifconfig:
$ ifconfig eth0 -multicast $ ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING> mtu 1500 [...] $ ifconfig eth0 multicast $ ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 [...]
While multicast enables multicast for the supplied interface name, -multicast disables it.
Since the deprecation of ifconfig, most of its functions have been taken over by another tool.
4. Using ip to Configure Multicast
The standard ip command is usually the first tool to turn to when checking network information.
Indeed, ip can tell us whether multicasting is available on our interface:
$ ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 01:00:00:66:60:10 brd ff:ff:ff:ff:ff:ff
In this case, we show all interfaces via link. Again, we see our [lo]opback and eth0 interfaces. Similar to the output of ifconfig, a comma-separated list within angle brackets includes the MULTICAST keyword, which indicates eth0 has multicasting enabled.
Moreover, we can see the actual addresses assigned for multicasting via another ip command line:
$ ip maddress show 1: lo inet 22.214.171.124 2: eth0 link 01:06:66:01:00:10 link 01:06:67:01:00:01 inet 126.96.36.199
Here, we use maddress to see the link and network layer multicast addresses. Once again, to check a specific interface, we can add it at the end of either command line.
Finally, as with ifconfig, we can also configure multicast via ip:
$ ip link set eth0 multicast off $ ip link show eth0 2: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 01:00:00:66:60:10 brd ff:ff:ff:ff:ff:ff $ ip link set eth0 multicast on $ ip link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 01:00:00:66:60:10 brd ff:ff:ff:ff:ff:ff
By using the ip link set command with our interface, we can turn multicast on or off.
5. Multicast Information
After looking at the main network interface configuration utilities, let’s explore some alternative sources of information about multicasting.
While not standardized, the netstat command is ubiquitous in the Linux world and beyond.
Its -g or –groups flag shows the multicast group memberships of our interfaces:
$ netstat --groups IPv6/IPv4 Group Memberships Interface RefCnt Group --------------- ------ --------------------- lo 1 all-systems.mcast.net eth0 1 all-systems.mcast.net
In the snippet above, if no groups are present, multicast is off. However, the presence of groups does not necessarily mean we have multicast enabled. In fact, disabling multicast on all interfaces would not change the output of netstat –groups.
The Internet Group Management Protocol (IGMP) is at the center of multicasting.
Since /proc and sysctl expose information about IGMP, we can leverage that for our needs:
$ cat /proc/net/igmp Idx Device : Count Querier Group Users Timer Reporter 1 lo : 1 V3 010000E0 1 0:00000000 0 2 eth0 : 1 V3 010000E0 1 0:00000000 0
Within /proc/net/igmp, we see both our interfaces with their group subscriptions. Alternatively, we can also use the /proc/net/igmp6 file.
In this article, we looked at many ways to check whether multicast is supported and enabled in a given system.
In conclusion, while we can get information about multicast with different methods, not all sources confirm the function is enabled.