Networking iptables dnat将私有ip映射到公共ip到特定ip

Networking iptables dnat将私有ip映射到公共ip到特定ip,networking,ip,mapping,iptables,Networking,Ip,Mapping,Iptables,我用两台机器构建了一个专用网络,它们都有两个网络接口 这是网络信息: 机器1 eth0 10.0.0.11(私人网络) eth1 10.82.80.208(校园网ip) 机器2 eth0 10.0.0.21(私人网络) eth210.82.80.207(校园网ip) 我想在校园网中访问我的计算机(10.82.80.206)中的10.0.0.11,而不是通过iptablesdnat使用校园网IP地址。例如,我想将数据包的目的地从10.0.0.11更改为10.82.80.208 我正在尝

我用两台机器构建了一个专用网络,它们都有两个网络接口 这是网络信息:

  • 机器1

    • eth0 10.0.0.11
      (私人网络)
    • eth1 10.82.80.208
      (校园网ip)
  • 机器2

    • eth0 10.0.0.21
      (私人网络)
    • eth210.82.80.207
      (校园网ip)
我想在校园网中访问我的计算机(
10.82.80.206
)中的
10.0.0.11
,而不是通过
iptables
dnat
使用校园网IP地址。例如,我想将数据包的目的地从
10.0.0.11
更改为
10.82.80.208

我正在尝试使用iptables命令,例如:

iptables -t nat -A PREROUTING -i eth0 -p tcp -d 10.0.0.11 -j DNAT --to-destination 10.82.80.208
iptables -t nat -A PREROUTING -i eth0 -p icmp -d 10.0.0.11 -j DNAT --to-destination 10.82.80.208
iptables -t nat -A PREROUTING -i eth0 -p udp -d 10.0.0.11 -j DNAT --to-destination 10.82.80.208
但是,当我尝试ping
10.0.0.11
时,它似乎没有用,主机仍然无法访问,我如何才能将我机器中口袋的目标从
10.0.0.11
更改为
10.82.80.208

据报道,
-i
标志指定输入接口,而您需要指定输出接口的
-o
标志:

[!] -i, --in-interface name
Name of an interface via which a packet was received (only for packets entering the INPUT, FORWARD and PREROUTING chains). When the "!" argument is used before the interface name, the sense is inverted. If the interface name ends in a "+", then any interface which begins with this name will match. If this option is omitted, any interface name will match.
[!] -o, --out-interface name
Name of an interface via which a packet is going to be sent (for packets entering the FORWARD, OUTPUT and POSTROUTING chains). When the "!" argument is used before the interface name, the sense is inverted. If the interface name ends in a "+", then any interface which begins with this name will match. If this option is omitted, any interface name will match.
但是,我认为在您的情况下,不需要指定接口或协议。我建议使用以下命令:

iptables -t nat -A PREROUTING -d 10.0.0.11 -j DNAT --to-destination 10.82.80.208

这个问题在这里似乎离题了。你应该问一下。