1. Introduction

Internet Protocl (IP) multicast is a convenient way to group network clients by letting them subscribe to messages they are interested in. However, it may be disabled or not even part of the kernel.

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.

Yet, one way to see what was baked into the kernel is by downloading the sources. To do that on Debian, we can use apt-get as long as we have the necessary prerequisites:

# 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

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

Although deprecated in favor of iproute by the majority of distributions, the net-tools package and ifconfig, in particular, are still around and heavily used.

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
2:      eth0
        link  01:06:66:01:00:10
        link  01:06:67:01:00:01

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.

5.1. netstat

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

Here, the all-systems.mcast.net domain resolves to the multicast as dictated by Internet Assigned Numbers Authority (IANA).

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.

5.2. /proc/net/igmp

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.

6. Summary

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.

Comments are closed on this article!