In this post going to see how to configure network interface with multicast address in linux.
Multicast will send information to a group of destination simultaneously.
Most probably class D(224.0.0.0 – 239.255.255.255) IP Address used in multicasting
Enable/ Disable Multicast:
Enabling Multicast:
#ifconfig eth0 multicast
once enabled check using #ifconfig eth0 command and you can find a line like below from the output of this command.
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Disbaling muticast:
# ifconfig eth0 -multicast
follow the same command to check the status
# ifconfig eth0
UP BROADCAST MTU:1500 Metric:1
We could see there is no word mentioned in this output like “MULTICAST”
Check whether multicast enabled in Kernel or not.
#grep -i multi /boot/config-<Kernel version>
* CONFIG_IP_MULTICAST=y #if “CONFIG_IP_MULTICAST” value mentioned as “n” then multicast disabled. We should make it as “y” (yes)
* CONFIG_IP_ROUTER=y
* CONFIG_IP_MROUTE=y
* CONFIG_NET_IPIP=y
* CONFIG_IP_MULTICAST=y #if “CONFIG_IP_MULTICAST” value mentioned as “n” then multicast disabled. We should make it as “y” (yes)
* CONFIG_IP_ROUTER=y
* CONFIG_IP_MROUTE=y
* CONFIG_NET_IPIP=y
Configure Network interface to send muticast traffic over the network:
We should add a default gateway to multicast traffic, to the specific Network Interface. Use the below command to add default route
# route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
Then check the default route
# route -n
You will get output like below
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
224.0.0.0 0.0.0.0 240.0.0.0 U 0 0 0 eth0
Destination Gateway Genmask Flags Metric Ref Use Iface
224.0.0.0 0.0.0.0 240.0.0.0 U 0 0 0 eth0
Command to check the multicast group in our host
# netstat -g
# cat proc/net/igmp
From the above commans will get output with multicast address for eth0 interface.
Now we configured a network interface with multicast address.