Linux 7 Multicast Configuration: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(28 intermediate revisions by the same user not shown)
Line 13: Line 13:
Make sure multicast is enabled at kernel level.  
Make sure multicast is enabled at kernel level.  


To compile multicast support into the kernel, CONFIG_IP_MULTICAST must be present in the kernel configuration file.
To compile multicast support into the kernel, CONFIG_IP_MULTICAST must be present in the kernel configuration file. The kernels are usually compiled with multicast support. If <tt>netstat -ng</tt> shows multicast groups being registered to, it means multicast support is available in kernel. For more details, see [[#Troubleshooting|Troubleshooting]] below.


==Multicast Support at Interface Level==
==Multicast Support at Interface Level==


* Verify that the network interface you plan to use for multicast traffic has multicast enabled, and if not, turn it on.
Verify that the network interface you plan to use for multicast traffic has multicast enabled, and if not, turn it on. This can be done with the [[Linux ip|ip]] utility, as described here [[Linux_ip#Change_MULTICAST_Flag_on_Device|Change MULTICAST Flag on Device]].
* Configure multicast routing: [[Linux_Routing_Configuration#Adding_Multicast_Routing_to_a_Specific_Network_Interface|Configure Multicast Routing]]
* If iptables runs on the system, allow multicast traffic for the interface that will handle multicast traffic: [[Iptables_Command_Line_Tool_Examples#Multicast|Configure iptables to allow Multicast]]
* Test it. For more details see the [[#Troubleshooting|Troubleshooting]] section.


=/proc=
<pre>
ip addr
</pre>
 
Look for MULTICAST flag:
 
<pre>
[eap@app01 ~]$ ip addr
...
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:cd:76:d7 brd ff:ff:ff:ff:ff:ff
...
</pre>
 
To turn on:
 
<pre>
ip link set dev <interface-name> multicast on
</pre>


==/proc/net/dev_mcast==
<span id='lshw_multicast'></span>Another way of determining whether multicast is configured on a network interface is to use <tt>[[lshw#Use|lshw]]</tt> as described below:


Contains Layer2 multicast groups which a device is listening to (interface index, label, number of references, number of bound addresses).
<pre>
lshw -class network
</pre>
 
Multicast configuration will be listed under the "configuration" section:
 
<pre>
configuration: ... multicast=yes ...
</pre>
 
==Multicast Routing==
 
Configure multicast routing, ensuring the multicast traffic is routed to the appropriate interface, and the route configuration survives reboot. The route we need is 224.0.0.0/4.
 
<pre>
ip route add 224.0.0.0/4 dev <device-name>
</pre>
 
For more details, see [[Linux_Routing_Configuration#Adding_Multicast_Routing_to_a_Specific_Network_Interface|Configure Multicast Routing]].
 
==iptables Configuration==
 
If iptables runs on the system, it must be configured to allow multicast traffic for the interface that will handle multicast traffic. Details on how to do that are available here:
 
{{Internal|Iptables_Command_Line_Tool_Examples#Multicast|Configure iptables to allow Multicast}}


==/proc/net/igmp==
==IP Forwarding==


Contains IPv4 multicast groups joined by this host.
Consider enabling [[IP Forwarding]].


==/proc/net/igmp6==
==Test==


Contains IPv6 multicast groups joined by this host.
Ping and generate multicast traffic. For more details see the [[#Troubleshooting|Troubleshooting]] section.


=Troubleshooting=
=Troubleshooting=
This section describes the sequence of steps to troubleshoot O/S (Linux)-level multicast problems.
* Make sure [[#Multicast_at_Kernel_Level|multicast is enabled in the kernel]].


==Display Multicast Group Membership Information==
==Display Multicast Group Membership Information==
Line 54: Line 96:
</pre>
</pre>


For more details on these files see [#.2Fproc|/proc]] above.
For more details on these files see [[#.2Fproc|/proc]] above.
 
<tt>ip</tt> has multicast querying abilities. See:
 
{{Internal|Linux_ip#Multicast|ip Multicast Support}}


==Ping==
==Ping==
A host with multicast enabled will listen by default to 224.0.0.1, so all the hosts on the network can be pinged.
<pre>
ping -c 10 224.0.0.1
</pre>
The networking subsystem might have to be reconfigured to not ignore broadcast ping:
<pre>
echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
</pre>


==Send Multicast Traffic==
==Send Multicast Traffic==


See {{Internal|Java Network Traffic Generator|Java Network Traffic Generator}}
<pre>
./bin/ntg receive --protocol=multicast --address=225.5.5.5:5555
./bin/ntg send --protocol=multicast --address=225.5.5.5:5555
</pre>
For more details, see {{Internal|Java Network Traffic Generator|Java Network Traffic Generator}}
 
==Other Ideas==


=Organizatorium=
<pre>
strace -f socat -  UDP4-DATAGRAM:$GRP:$PORT,ip-add-membership=$GRP:$IFACE,bind=0.0.0.0:$PORT,multicast-loop=0
</pre>


TODO http://lartc.org/howto/lartc.multicast.html
=<tt>/proc</tt>=
 
==<tt>/proc/net/dev_mcast</tt>==
 
Contains Layer2 multicast groups which a device is listening to (interface index, label, number of references, number of bound addresses).
 
==<tt>/proc/net/igmp</tt>==
 
Contains IPv4 multicast groups joined by this host.
 
==<tt>/proc/net/igmp6</tt>==
 
Contains IPv6 multicast groups joined by this host.


=TODO=


echo 1 > /proc/sys/net/ipv4/ip_forward
* <font color=red>Integrate and deplete https://home.feodorov.com:9443/wiki/Wiki.jsp?page=MulticastOnLinux</font>

Latest revision as of 14:35, 29 June 2017

Internal

Concepts

Multicast

Procedure

Multicast at Kernel Level

Make sure multicast is enabled at kernel level.

To compile multicast support into the kernel, CONFIG_IP_MULTICAST must be present in the kernel configuration file. The kernels are usually compiled with multicast support. If netstat -ng shows multicast groups being registered to, it means multicast support is available in kernel. For more details, see Troubleshooting below.

Multicast Support at Interface Level

Verify that the network interface you plan to use for multicast traffic has multicast enabled, and if not, turn it on. This can be done with the ip utility, as described here Change MULTICAST Flag on Device.

ip addr

Look for MULTICAST flag:

[eap@app01 ~]$ ip addr
...
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:cd:76:d7 brd ff:ff:ff:ff:ff:ff
...

To turn on:

ip link set dev <interface-name> multicast on

Another way of determining whether multicast is configured on a network interface is to use lshw as described below:

lshw -class network

Multicast configuration will be listed under the "configuration" section:

configuration: ... multicast=yes ...

Multicast Routing

Configure multicast routing, ensuring the multicast traffic is routed to the appropriate interface, and the route configuration survives reboot. The route we need is 224.0.0.0/4.

ip route add 224.0.0.0/4 dev <device-name>

For more details, see Configure Multicast Routing.

iptables Configuration

If iptables runs on the system, it must be configured to allow multicast traffic for the interface that will handle multicast traffic. Details on how to do that are available here:

Configure iptables to allow Multicast

IP Forwarding

Consider enabling IP Forwarding.

Test

Ping and generate multicast traffic. For more details see the Troubleshooting section.

Troubleshooting

This section describes the sequence of steps to troubleshoot O/S (Linux)-level multicast problems.

Display Multicast Group Membership Information

netstat -g

displays multicast group membership information for IPv4 and IPv6. Optionally use -n to prevent DNS lookups (faster).

The same information can be obtained from /proc:

cat /proc/net/dev_mcast
cat /proc/net/igmp
cat /proc/net/igmp6

For more details on these files see /proc above.

ip has multicast querying abilities. See:

ip Multicast Support

Ping

A host with multicast enabled will listen by default to 224.0.0.1, so all the hosts on the network can be pinged.

ping -c 10 224.0.0.1

The networking subsystem might have to be reconfigured to not ignore broadcast ping:

echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Send Multicast Traffic

./bin/ntg receive --protocol=multicast --address=225.5.5.5:5555
./bin/ntg send --protocol=multicast --address=225.5.5.5:5555

For more details, see

Java Network Traffic Generator

Other Ideas

strace -f socat -  UDP4-DATAGRAM:$GRP:$PORT,ip-add-membership=$GRP:$IFACE,bind=0.0.0.0:$PORT,multicast-loop=0

/proc

/proc/net/dev_mcast

Contains Layer2 multicast groups which a device is listening to (interface index, label, number of references, number of bound addresses).

/proc/net/igmp

Contains IPv4 multicast groups joined by this host.

/proc/net/igmp6

Contains IPv6 multicast groups joined by this host.

TODO