iptables 中用于 TCP 连接的 DNAT 转换

问题描述 投票:0回答:1

我最近开始处理 iptables,我有这个问题。假设我有一个 DNAT 规则,它将发往前端 IP 的 TCP 数据包转发到后端 IP,即服务器(例如 server1)。该后端 server1 已启动并正在运行,并且我们已经建立了 TCP 连接,客户端正在向前端 IP 发送和接收数据包,该前端 IP 正在 DNAT 到 server1 IP。现在,如果有一个新的后端服务器(例如 server2),并且删除了该规则,并使用 server2 的后端 IP 添加了新的 DNAT 规则,同时 server1 也启动了。现在据我所知,使用 TCP 连接到前端 IP 的新尝试将被 DNATed 到 server2,但是已经建立的到 server1 的连接会发生什么。根据我的观察,客户端正在向 server1 发送 TCP 数据包,即使 iptables 规则在客户端运行的系统上是

tcp to server2

tcp iptables
1个回答
0
投票

看起来答案如下

This table is slightly different from the `filter' table, in that only the first packet of a new connection will traverse the table: the result of this traversal is then applied to all future packets in the same connection.
,在https://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-3.html#ss3.2

中提到
© www.soinside.com 2019 - 2024. All rights reserved.