如果数据包的源地址为 192.168.86.212,目标地址为 192.168.86.212,则我尝试在 iptables 中执行 DNAT 规则,将目标地址更改为 172.217.5.100。
sudo iptables -t nat -A PREROUTING -s 192.168.86.213/32 -d 192.168.96.212/32 -j DNAT -to-destination 172.217.5.100
但我收到了这个错误信息:
Bad argument `172.217.5.100'
Try `iptables -h' or 'iptables --help' for more information.
我对 Ubuntu 还很陌生,如能得到任何帮助我将不胜感激!
答案1
从 开始man iptables-extensions
,DNAT
目标选项是--to-destination
(带有两个破折号)而不是-to-destination
:
DNAT
This target is only valid in the nat table, in the PREROUTING and OUT‐
PUT chains, and user-defined chains which are only called from those
chains. It specifies that the destination address of the packet should
be modified (and all future packets in this connection will also be
mangled), and rules should cease being examined. It takes the follow‐
ing options:
--to-destination [ipaddr[-ipaddr]][:port[-port]]
ipaddr
错误消息标记的是参数而不是选项本身,这一点并不明显。