Arm*_*ile 5 linux routing iptables forwarding packet
我在配置 iptables 时遇到了麻烦:一些客户端向服务器发送消息。我希望主机服务器在本地处理消息(主机 A,正常情况下),但另外对于每条消息(tcp 数据包)将数据包的副本发送到另一台主机(主机 B,运行服务器的修改版本,我想看看相同消息的行为如何,以便我可以比较两台服务器)。应该用iptables来完成。我已尝试使用以下命令。这些将数据包发送到 B,但主机 A 不处理消息(应该由第二个命令完成?)。
iptables -t nat -A PREROUTING -p tcp --dport 31090 -j DNAT --to-destination IP_HOST_B:32090
iptables -t nat -A POSTROUTING -p tcp --dport 32090 -j SNAT --to-source IP_HOST_A:31090
Run Code Online (Sandbox Code Playgroud)
我在配置中遗漏了什么来实现我的目标?
谢谢你。
一些注意事项:
\n\n为了复制数据包,您可以使用 TEE target , cf man iptables-extensions:
\n\n\n球座
\n\nRun Code Online (Sandbox Code Playgroud)\nThe TEE target will clone a packet and redirect this clone\n to another machine on the local network segment. In other\n words, the nexthop must be the target, or you will have to\n configure the nexthop to forward it further if so desired.\n\n --gateway ipaddr\n Send the cloned packet to the host reachable at the\n given IP address. Use of 0.0.0.0 (for IPv4 pack\xe2\x80\x90\n ets) or :: (IPv6) is invalid.\n
在你的情况下,这将给出:
\n\niptables -t mangle -A POSTROUTING -p tcp --dport 31900 -j TEE --gateway IP_HOST_B\nRun Code Online (Sandbox Code Playgroud)\n\n但是,我怀疑这种数据包复制是否适合您的情况,因为使用了 TCP。TCP 旨在在客户端和服务器之间建立连接。在这里,您会遇到一个客户端和 2 个服务器的情况:将会出现问题。
\n| 归档时间: |
|
| 查看次数: |
8650 次 |
| 最近记录: |