具有双以太网接口的 ffmpeg 工作错误

Cha*_*Cui 2 linux ffmpeg multicast

具有双接口的服务器。

  1. 其中一个(eht0)用于WAN,为互联网用户提供http/ssh服务。

  2. 另一个(eth1)用于接收来自内网的组播数据。

218.108.132.177 为公网网关。

125.210.198.1 是私网网关。

233.49.3.*/24 是多播地址。

10.0.11.*/24为组播数据源。

当路由表如下所示时,ffmpeg 无法从 eth1 读取 udp 数据,ffmpeg 挂起:

rrca@rcasnap02:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
218.108.132.176 *               255.255.255.252 U     0      0        0 eth0
125.210.198.0   *               255.255.255.240 U     0      0        0 eth1
default         218.108.132.177 0.0.0.0         UG    100    0        0 eth0
default         125.210.198.1   0.0.0.0         UG    100    0        0 eth1
Run Code Online (Sandbox Code Playgroud)

或者

rrca@rcasnap02:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
218.108.132.176 *               255.255.255.252 U     0      0        0 eth0
125.210.198.0   *               255.255.255.240 U     0      0        0 eth1
default         218.108.132.177 0.0.0.0         UG    100    0        0 eth0
10.0.11.0       125.210.198.1   0.0.0.0         UG    100    0        0 eth1
Run Code Online (Sandbox Code Playgroud)

或者

rrca@rcasnap02:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
218.108.132.176 *               255.255.255.252 U     0      0        0 eth0
125.210.198.0   *               255.255.255.240 U     0      0        0 eth1
default         218.108.132.177 0.0.0.0         UG    100    0        0 eth0
233.49.3.0      125.210.198.1   255.255.255.0   UG    100    0        0 eth1
Run Code Online (Sandbox Code Playgroud)

我想让ffmpeg正常工作,但现在我认为路由表中的两条默认路由互相干扰,我尝试一下,当公共网关路由被删除,或者私有网关路由位于公共默认网关路由的头部时,ffmpeg 工作得很好,我认为它从 eth1 读取多播。但是路由表不是这样,ffmpeg 无法从 eth1 读取数据,我认为它读取 eth0 上的数据(这不是专用网络接口)。

如何让ffmpeg同时在两个接口上正常工作?

Kri*_*ost 5

您需要为组播流量配置正确的路由。内核对所有传入的多播流量进行来源检查:如果它到达的接口与用于发送此类流量的接口不同,则会被丢弃。

只需在 eth1 接口上设置多播路由:

# route add -net 224.0.0.0/8 dev eth1
Run Code Online (Sandbox Code Playgroud)

或者,禁用来源检查:

# echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
Run Code Online (Sandbox Code Playgroud)