Dan*_*iel 0 linux nat iptables
我的 Linux 服务器上有一个 VPN,它执行 IPv4 NAT,例如:
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT --to-source 1.2.3.4
Run Code Online (Sandbox Code Playgroud)
但是,我想为每个内部 10.8.0.0/24 ip 设置静态临时端口范围,以便更轻松地记录哪个客户端连接到哪个客户端,这可以使用 iptables 吗?
例如,端口 1000-2500 将是 10.8.0.10 使用的临时端口,10000-20000 将用于 10.8.0.20 等。
我已经搜索过谷歌,但找不到任何东西。
检查 MASQUERADE 目标而不是 SNAT:它支持以下选项:
--to-ports port[-port]
This specifies a range of source ports to use, overriding the
default SNAT source port-selection heuristics (see above). This
is only valid if the rule also specifies one of the following
protocols: tcp, udp, dccp or sctp.
Run Code Online (Sandbox Code Playgroud)
我从不使用它,但测试!但它只适用于 tcp、udp。对于其他人,如ICMP,运气不好,没有端口......
归档时间: |
|
查看次数: |
1051 次 |
最近记录: |