多个接口的多播路由设置

多个接口的多播路由设置

目前,我有以下 eth5 来接收 239.1.1.31 的多播数据。它有效。

$ ifconfig
eth5      Link encap:Ethernet  HWaddr E4:11:5B:94:E1:F3
          inet addr:10.185.2.2  Bcast:10.185.2.31  Mask:255.255.255.224
...

路线:

$ sudo ip route add 10.0.8.0/24 via 10.185.2.14 dev eth5
$ sudo ip route add 224.0.0.0/4 dev eth5

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.185.2.0      0.0.0.0         255.255.255.224 U     1      0        0 eth5
10.0.8.0        10.185.2.14     255.255.255.0   UG    0      0        0 eth5
224.0.0.0       0.0.0.0         240.0.0.0       U     0      0        0 eth5

结果:

$ iperf -s -u -B 239.1.1.31 -p 51000 -i 1
------------------------------------------------------------
Server listening on UDP port 51000
Binding to local address 239.1.1.31
Joining multicast group  239.1.1.31
Receiving 1470 byte datagrams
UDP buffer size:  224 KByte (default)
------------------------------------------------------------
[  3] local 239.1.1.31 port 51000 connected with 10.0.8.50 port 53253
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0- 1.0 sec  0.00 Bytes  0.00 bits/sec   0.000 ms    0/    0 (-nan%)
[  3]  1.0- 2.0 sec  16.0 Bytes   128 bits/sec   0.000 ms 268435481/268435482 (1e+02%)
[  3]  2.0- 3.0 sec  0.00 Bytes  0.00 bits/sec   0.000 ms    0/    0 (-nan%)
...

$ sudo tcpdump -i eth5 dst host 239.1.1.31
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth5, link-type EN10MB (Ethernet), capture size 65535 bytes
13:57:46.194477 IP 10.0.8.32.41686 > 239.1.1.31.pago-services1: UDP, length 512
13:57:46.348176 IP 10.0.10.32.53089 > 239.1.1.31.pago-services2: UDP, length 512
13:57:46.562028 IP 10.0.8.41.48791 > 239.1.1.31.60001: UDP, length 24
...

现在我又多了一个接口 eth4 来接收 239.1.1.201 的多播数据:

$ ifconfig
eth4      Link encap:Ethernet  HWaddr E4:11:5B:94:E1:F2
          inet addr:10.185.130.2  Bcast:10.185.130.31  Mask:255.255.255.224

以下命令失败。

$ sudo ip route add 10.0.8.0/24 via 10.185.130.14 dev eth4
RTNETLINK answers: File exists
$ sudo ip route add 224.0.0.0/4 dev eth4
RTNETLINK answers: File exists

我应该如何从两个接口接收多播数据?谢谢。

相关内容