$linuxjunkies
>

Multicast Networking on Linux

Configure IPv4/IPv6 multicast on Linux: addressing, IGMP group membership, interface flags, and live testing with iperf3 and socat.

AdvancedUbuntuDebianFedoraArch12 min readUpdated June 7, 2026

Before you start

  • Root or sudo access on all hosts involved
  • iperf3 and socat installed (see install commands in guide)
  • Hosts on the same Layer 2 segment, or a multicast-routing-enabled network for cross-subnet tests
  • Basic familiarity with ip/iproute2 commands and UDP networking

Multicast lets a single packet stream reach many receivers simultaneously without the sender duplicating traffic per host. It underpins IPTV, service discovery (mDNS, OSPF, PIM), financial market feeds, and media production networks. Unlike broadcast, multicast is group-scoped and routed deliberately — but it requires deliberate configuration to work reliably on Linux. This guide covers the addressing model, IGMP membership, joining groups from userspace, and practical testing with iperf3 and socat.

Multicast Addressing Fundamentals

IPv4 multicast addresses occupy 224.0.0.0/4 (224.0.0.0 – 239.255.255.255). The key ranges you will encounter:

  • 224.0.0.0/24Link-local, TTL 1. Used by routing protocols (OSPF: 224.0.0.5/6, PIM: 224.0.0.13). Never routed.
  • 239.0.0.0/8 — Organization-local scope. The safe default for private applications.
  • 224.0.1.0 – 238.255.255.255 — Globally scoped; avoid unless registered with IANA.

IPv6 multicast starts with ff00::/8. The second byte encodes flags and scope (e.g., ff02::1 is all-nodes link-local). Most concepts below apply equally to IPv6; commands show both where they differ.

At Layer 2, IPv4 multicast addresses map to MAC addresses in the 01:00:5e:xx:xx:xx range. The NIC's multicast filter is programmed when you join a group so frames are not dropped by the hardware.

IGMP — How Hosts Signal Group Membership

Internet Group Management Protocol (IGMP) is exchanged between hosts and the directly attached router (or switch with IGMP snooping). Linux implements the full IGMPv3 stack in the kernel.

  • IGMPv1 — Basic join; no explicit leave.
  • IGMPv2 — Adds explicit leave; widely supported.
  • IGMPv3 — Source-specific multicast (SSM); default on modern kernels.

Check the current version and active memberships on an interface:

cat /proc/net/igmp

Output lists each group in hex per interface. To see human-readable active memberships:

ip maddr show dev eth0

Every interface automatically joins 224.0.0.1 (all-hosts) and the solicited-node multicast address for each IPv6 address assigned.

Kernel and Interface Prerequisites

Enable IP Multicast Routing (if forwarding between interfaces)

For a host that only receives multicast on one interface, no extra kernel option is needed. To forward multicast between interfaces you need a multicast routing daemon (smcroute or pimd) and these sysctl values:

sysctl -w net.ipv4.conf.all.mc_forwarding=1
sysctl -w net.ipv4.ip_forward=1

To persist across reboots, add them to /etc/sysctl.d/99-multicast.conf.

Check Interface Multicast Flag

An interface must have the MULTICAST flag:

ip link show eth0

Look for MULTICAST in the flags field. If missing (rare on physical NICs), enable it:

ip link set eth0 multicast on

Disable Reverse Path Filtering on the Receive Interface

Strict RPF (value 1) can silently drop multicast packets whose source address does not match the routing table. Set it to loose (2) or off (0) on the interface receiving multicast:

sysctl -w net.ipv4.conf.eth0.rp_filter=2

Joining a Multicast Group

Method 1 — iproute2 (manual, no application)

Add a static group membership for testing without running an application:

ip maddr add 239.1.2.3 dev eth0

Remove it the same way with del. This instructs the kernel to send an IGMP join and program the NIC filter, but no socket is listening — useful only to verify switch/router behaviour.

Method 2 — socat (userspace join and receive)

Install socat:

# Debian/Ubuntu
apt install socat

# Fedora/RHEL
dnf install socat

# Arch
pacman -S socat

Receive UDP multicast on group 239.1.2.3 port 5000, bound to interface eth0:

socat UDP4-RECVFROM:5000,ip-add-membership=239.1.2.3:eth0,fork -

This opens a socket, calls IP_ADD_MEMBERSHIP via the socket option, and prints received data to stdout. The kernel sends an IGMPv3 report automatically when the socket option is set.

Send a test packet from another terminal (or another host on the same subnet):

echo "hello multicast" | socat - UDP4-DATAGRAM:239.1.2.3:5000,ip-multicast-if=eth0

Testing Multicast Bandwidth with iperf3

iperf3 supports UDP multicast natively. Install it:

# Debian/Ubuntu
apt install iperf3

# Fedora/RHEL
dnf install iperf3

# Arch
pacman -S iperf3

Receiver (server) side

iperf3 in server mode will join the multicast group when the client specifies one. Bind to the multicast group address and specify the interface:

iperf3 --server --bind 239.1.2.3 --interface eth0

Note: iperf3 multicast support is one-to-many for UDP only. Run this on every host that should receive the stream.

Sender (client) side

iperf3 --client 239.1.2.3 --udp --bandwidth 10M --time 30 --bind-dev eth0

Flags used: --udp selects UDP (required for multicast), --bandwidth sets the send rate, --bind-dev selects the outgoing interface. All receivers in the group will report independently.

Setting TTL / Hop Limit

Link-local multicast (224.0.0.0/24) is TTL 1 by default and will not cross a router. For routed multicast set a higher TTL:

iperf3 --client 239.1.2.3 --udp --bandwidth 10M --ttl 10 --bind-dev eth0

Inspecting and Verifying Group State

Confirm IGMP reports are sent

tcpdump -i eth0 -n igmp

You should see v3 report packets when a socket joins a group, and leave packets on IGMPv2 networks when it leaves. On an IGMPv3 network leave is expressed as a TO_IN report with an empty source list.

Verify multicast routes (if routing)

ip mroute show

Populated only when a multicast routing daemon (smcroute, pimd, or pim6sd) is running and has installed routes. Empty output on a receive-only host is normal.

Watch live group membership counters

watch -n 1 'ip maddr show'

Firewall Considerations

Multicast traffic uses UDP and hits the INPUT chain. With nftables:

nft add rule inet filter input ip daddr 239.1.2.3 udp dport 5000 accept

With firewalld:

firewall-cmd --add-rich-rule='rule family="ipv4" destination address="239.1.2.3" port port="5000" protocol="udp" accept' --permanent
firewall-cmd --reload

With ufw (Ubuntu/Debian default):

ufw allow in to 239.1.2.3 port 5000 proto udp

Also ensure IGMP itself is not blocked; it uses IP protocol 2, not TCP/UDP:

nft add rule inet filter input ip protocol igmp accept

Troubleshooting

  • Packets sent but not received on the same host: Check that the sending socket is not inadvertently using IP_MULTICAST_LOOP=0. By default loopback is enabled; some applications disable it.
  • Works locally, fails across switch: The switch likely has IGMP snooping enabled. If the snooping querier is missing, the switch may flood or drop multicast. Verify with the switch's management interface or add a querier.
  • Works on the subnet, fails across router: The router must run a multicast routing protocol (PIM-SM or PIM-DM) and have it enabled on both interfaces. A TTL of 1 will also stop the packet at the first hop — raise it.
  • Packets drop under load: Increase the socket receive buffer. For iperf3 use --window; for custom applications set SO_RCVBUF or tune net.core.rmem_max via sysctl.
  • RPF drops: Run tcpdump on the interface and compare with /proc/net/stat/rt_cache drop counters. Set rp_filter=2 as shown above.
tested on:Ubuntu 24.04Fedora 40Debian 12Arch rolling

Frequently asked questions

Why do I receive my own multicast packets on the same host?
The kernel enables IP_MULTICAST_LOOP by default so that local sockets in the same group receive locally sent packets. Disable it with setsockopt(IP_MULTICAST_LOOP, 0) in your application or pass the appropriate flag in socat/iperf3 if you want to suppress local loopback.
What is the difference between ASM and SSM multicast?
Any-Source Multicast (ASM) lets any sender transmit to a group; receivers get traffic from all sources. Source-Specific Multicast (SSM, address range 232.0.0.0/8 for IPv4) ties the group membership to a specific source IP, reducing unwanted traffic and simplifying routing. SSM uses IGMPv3 INCLUDE mode.
Does multicast work across a VPN or VXLAN overlay?
It depends on the overlay. Some VXLAN implementations use an underlay multicast group to replicate BUM traffic, which means the physical network must support multicast. Most IPsec and WireGuard VPNs do not forward multicast natively; you need smcroute or a GRE tunnel to carry it.
Why does multicast stop working after the application exits?
When the last socket holding an IP_ADD_MEMBERSHIP on a group closes, the kernel sends an IGMP leave message and removes the group from the NIC filter. Static memberships added with 'ip maddr add' persist until explicitly removed or the interface goes down.
How do I debug IGMP snooping issues on a managed switch?
Check whether the switch has an IGMP querier active on the VLAN; without a querier, membership tables may time out. On Cisco/Arista you can inspect the mcast group table with 'show ip igmp snooping groups'. On Linux bridges, enable bridge multicast snooping and optionally the built-in querier via 'ip link set <bridge> type bridge mcast_querier 1'.

Related guides