如果没有 promisc,UDP 多播将无法工作。已尝试过 rp_filter=0

如果没有 promisc,UDP 多播将无法工作。已尝试过 rp_filter=0

我在 Ubuntu Maverick 中遇到了多播流量问题。它似乎仅在卡处于混杂模式时才起作用(即如果我手动设置它,或者使用 tcpdump 等工具)。

正在添加多播路由...

user@pc-149:~$ sudo ip route add multicast 224.0.0.0/4 dev eth0
user@pc-149:~$ cat /proc/net/igmp
Idx Device    : Count Querier   Group    Users Timer    Reporter
1   lo        :     1      V3
            010000E0     1 0:00000000       0
2   eth0      :     2      V3
            FB0000E0     1 0:00000000       0
            010000E0     1 0:00000000       0
3   eth1      :     1      V3
            010000E0     1 0:00000000       0

正在启动 mplayer 流转储...

user@pc-149:~$ mplayer udp://225.0.0.1:9000 -dumpstream -dumpfile /tmp/test.mpg
mplayer: Symbol \`ff_codec_wav_tags' has different size in shared object, consider re-linking
mplayer: Symbol \`ff_codec_bmp_tags' has different size in shared object, consider re-linking
MPlayer 1.0rc4-4.4.5 (C) 2000-2010 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing udp://225.0.0.1:9000.
STREAM_UDP, URL: udp://225.0.0.1:9000
Timeout! No data from host 225.0.0.1
udp_streaming_start failed
No stream found to handle url udp://225.0.0.1:9000


Exiting... (End of file)

它确实正确地添加到了多播组(同时尝试读取流)

user@pc-149:~$ cat /proc/net/igmp
Idx Device    : Count Querier   Group    Users Timer    Reporter
1   lo        :     1      V3
            010000E0     1 0:00000000       0
2   eth0      :     3      V3
            010000E1     1 0:00000000       0
            FB0000E0     1 0:00000000       0
            010000E0     1 0:00000000       0
3   eth1      :     1      V3
            010000E0     1 0:00000000       0

但 tcpdump 看到了流量

user@pc-149:~$ sudo tcpdump -vv -i eth0 dst 225.0.0.1
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:47:40.698483 IP (tos 0x0, ttl 64, id 23281, offset 0, flags [none], proto UDP (17), length 1344)
    ls5.3203 > 225.0.0.1.9000: [udp sum ok] UDP, length 1316
09:47:40.698793 IP (tos 0x0, ttl 64, id 23283, offset 0, flags [none], proto UDP (17), length 1344)
    ls5..3203 > 225.0.0.1.9000: [udp sum ok] UDP, length 1316

棘手的部分是,只要卡处于混杂模式(即运行 tcpdump 时),mplayer 也可以看到流量……

我也检查了 rp_filter 的东西......

root@pc-149:~# sysctl -a | grep \\.rp_filter
error: "Invalid argument" reading key "fs.binfmt_misc.register"
error: permission denied on key 'net.ipv4.route.flush'
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth1.rp_filter = 0
error: permission denied on key 'net.ipv6.route.flush'

这是我的路线信息

root@pc-149:~# ip route show
10.10.14.0/24 dev eth0  proto kernel  scope link  src 10.10.14.100  metric 1 
169.254.0.0/16 dev eth0  scope link  metric 1000 
multicast 224.0.0.0/4 dev eth0  scope link 
default via 10.10.14.xxx dev eth0  proto static 

root@pc-149:~# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 5c:26:0a:xx:xx:xx  
      inet addr:10.10.14.xxx  Bcast:10.10.14.255  Mask:255.255.255.0
      inet6 addr: fe80::5e26:aff:xxxx:xxxx/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:155843 errors:0 dropped:0 overruns:0 frame:0
      TX packets:82366 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:189808267 (189.8 MB)  TX bytes:7068802 (7.0 MB)
      Interrupt:20 Memory:e9600000-e9620000 

更新: 因此,在看了这里的另一篇文章后,我使用 smcroute 后,它就可以正常工作了,但我认为这并不能解决根本问题。顺便说一句,在 centos 5.5 上,只需添加多播路由就可以正常工作,因此 Ubuntu 的做法存在根本性的不同

相关内容