我想将接口上的所有传入流量重新路由ens4f0
到 IP 地址 192.168.50.10,但 Wireshark 显示传入数据包上的目标 IP 地址未发生改变。这是预期的行为吗?我以为 PREROUTING 比其他任何东西都先进入了?
我的iptables
命令是:
# iptables -t nat -A PREROUTING -i ens4f0 -j DNAT --to 192.168.50.10
# iptables -t nat -vL
Chain PREROUTING (policy ACCEPT 24618 packets, 1923K bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT all -- ens4f0 any anywhere anywhere to:192.168.50.8
0 0 DNAT all -- ens4f0 any anywhere anywhere to:192.168.50.10
0 0 DNAT all -- ens4f0 any anywhere anywhere to:192.168.50.10
我知道传入的数据包来自 192.168.50.8,因此我也尝试过:
# iptables -t nat -A PREROUTING -i ens4f0 -j DNAT -s 192.168.50.8/32 --to 192.168.50.10
# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT all -- anywhere anywhere to:192.168.50.8
DNAT all -- anywhere anywhere to:192.168.50.10
DNAT all -- anywhere anywhere to:192.168.50.10
DNAT all -- 192.168.50.8 anywhere to:192.168.50.10
答案1
Wireshark 捕获传入数据包前它们由防火墙处理(以及出站数据包后由于防火墙会处理这些数据包,因此您无法在此数据包捕获中看到防火墙对入站数据包所做的更改。请尝试在出站接口上进行捕获以查看已修改的数据包。