复制所有传出的 IP 数据包

复制所有传出的 IP 数据包

我们的 ISP 出现了问题,75% 的传出 IP 数据包在以太网中丢失。传入数据包完全不受影响,我们认为我们没有受到限制,因为我们可以发送大量 UDP 数据包,而不会看到丢包率增加。

ISP 修复这个问题的速度非常慢(花了数周时间),我们需要自己实施一个变通方案,直到他们修复这个问题。一个看起来很有希望的解决方案是复制所有传出的 IP 数据包。我意识到这可能由于多种原因并不理想,但我们仍然想尝试一下。

是否可以复制所有传出的 IP 数据包?如果可以,如何复制?

我们主要使用 Ubuntu Server 20.04 LTS,但也有一些 Windows 10 Pro 桌面。

答案1

iptables -j TEE目标的设计目的正是克隆匹配的数据包:

man iptables-extensions

TEE
The TEE target will clone a packet and redirect this clone to 
another machine on the local network segment. In other words, 
the nexthop must be the target, or you will have to configure 
the nexthop to forward it further if so desired.

--gateway ipaddr
    Send the cloned packet to the host reachable at the given 
IP address. Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is 
invalid. 

To forward all incoming traffic on eth0 to an Network Layer 
logging box:

-t mangle -A PREROUTING -i eth0 -j TEE --gateway 2001:db8::1   

相关内容