
我在 Ubuntu 伺服器上使用 iptables 將公用 IP 路由到私人 IP。我想要 nat 所有流量,包括 80、443 和 ICMP。
然而,ICMP 似乎沒有路由。我對公用 IP 執行穩定的 ping 操作,並且永遠不會停止,即使 NAT 指向偽造的 IP。
以下是我正在使用的規則:
iptables -t nat -I PREROUTING -d 206.72.119.76 -j DNAT --to-destination 10.240.5.5
iptables -t nat -I POSTROUTING -s 10.240.5.5 -j SNAT --to-source 206.72.119.76
我專門嘗試了 ICMP 規則,但沒有這樣的運氣:
iptables -t nat -I PREROUTING -d 206.72.119.76 - icmp --icmp-type echo-request -j DNAT --to-destination 10.240.5.5
有任何想法嗎?
答案1
您是否執行過任何 pcapping 來查看 icmp 資料包是否經過 NAT 並再次發送出去?也許它們只是被你正在運行的盒子接受了iptables
。