发球后如何处理镜像(重复)iPtables流量



我有一个关于带有T恤选项iptables流量的问题。主要目标是将服务器A(端口1935)上服务的所有流量复制到同一端口上的服务器B上运行的同一服务(端口1935)。例如:如果我开始将视频流到192.168.0.200:1935-视频应在两个服务器上(192.168.0.0.201:1935和192.168.0.200:1935)。Google将我指向iptables -tee选项。我尝试在Ubuntu上使用它:服务-192.168.0.200服务B -192.168.0.201

在Serv A(192.168.0.200)上,我添加了1935年端口流量的镜像:

root@ubuntu_200:~# iptables -t mangle -A PREROUTING -p tcp --dport 1935 -d 192.168.0.200 -j TEE --gateway 192.168.0.201

我现在在Serv B(192.168.0.201)接口上获得了所有软件包。

root@ubuntu_201:~# tcpdump 'tcp port 1935'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
18:14:47.503241 IP 192.168.0.10.49984 > 192.168.0.200.1935: Flags [S], seq 3961116317, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
18:14:47.503258 IP 192.168.0.10.49985 > 192.168.0.200.1935: Flags [S], seq 1849647427, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
18:14:47.752702 IP 192.168.0.10.49986 > 192.168.0.200.1935: Flags [S], seq 3102326921, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
18:14:47.999309 IP 192.168.0.10.49984 > 192.168.0.200.1935: Flags [S], seq 3961116317, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
18:14:48.008983 IP 192.168.0.10.49985 > 192.168.0.200.1935: Flags [S], seq 1849647427, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
18:14:48.253066 IP 192.168.0.10.49986 > 192.168.0.200.1935: Flags [S], seq 3102326921, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
18:14:48.499660 IP 192.168.0.10.49984 > 192.168.0.200.1935: Flags [S], seq 3961116317, win 8192, options [mss 1460,nop,nop,sackOK], length 0
18:14:48.508964 IP 192.168.0.10.49985 > 192.168.0.200.1935: Flags [S], seq 1849647427, win 8192, options [mss 1460,nop,nop,sackOK], length 0
18:14:48.751863 IP 192.168.0.10.49986 > 192.168.0.200.1935: Flags [S], seq 3102326921, win 8192, options [mss 1460,nop,nop,sackOK], length 0

正如您所看到的,我在第二服务器接口上获得了所有流量,但带有Serv A的目标IP(192.168.0.200)。现在,我需要将此流量路由到1935年端口上的服务。我尝试在服务B上添加规则:

iptables -t nat -A PREROUTING -p tcp --dport 1935 -d 192.168.0.200 -j DNAT --to-destination 192.168.0.201:1935  

也尝试重定向和向前 - 但没有使其正常工作... Serv B端口上没有视频1935。

有人可以将我指向正确的方向吗?正如我之前提到的:我需要在1935端口的两个服务器上看到视频流。发布仅在Serv A上,但是视频应该在两者上。任何建议都会很高兴。谢谢。

我认为这是不可能这样做的。

看来您正在使用T恤进行TCP流量。

TCP是一种状态协议(与UDP不同),它要求用户结束计算机参与每个连接的步骤,并且它将与两个单独的客户端尝试与一台服务器进行通信。

一些替代方案:

  1. 而不是使用UDP流(当然,您必须同时更改服务器,客户端和可iptable规则)。
  2. 使用某种TCP代理,从一侧接受TCP视频流(或透明地拦截它),另一侧从另一侧接受2(或更多)对多个客户端的不同TCP会话。也许这可以在这里有所帮助:https://github.com/agnoster/duplicator

最新更新