具有3个公共IP和iptables的服务器

我有一个有两个网卡的Linux机箱:eth0和eth1。

在一张卡上我有3个公共IP:

  • eth0 = 10.10.10.1
  • eth0:1 = 10.10.10.2
  • eth0:2 = 10.10.10.3

在另一张卡上我有一个本地IP

  • eth1 = 192.9.200.1

我想将10.10.10.2的所有WANstream量redirect到LAN 192.9.200.2,10.10.10.3到192.9.200.3

我已经试过这个规则,但不起作用

iptables -t nat -A PREROUTING -i eth0 -d 10.10.10.2 -j DNAT --to-destination 192.9.200.2 iptables -t nat -A PREROUTING -i eth0 -d 10.10.10.3 -j DNAT --to-destination 192.9.200.3 

IP转发在/etc/sysctl.conf启用

如果您没有转发允许规则,您可能必须明确地允许使用:

 -A FORWARD -s 10.10.10.2 -d 192.9.200.2 -j ACCEPT -A FORWARD -s 10.10.10.3 -d 192.9.200.2 -j ACCEPT