上面的解釋為:
從外面進來eth1口的流量
從eht0口出去的流量
eth0 Link encap:Ethernet HWaddr 00:22:19:A9:58:A5
inet addr:10.3.0.204 Bcast:10.3.0.255 Mask:255.255.255.0 目标位址172.3.0.3:7001
eth1 Link encap:Ethernet HWaddr 00:22:19:A9:58:A7
inet addr:172.16.0.90 Bcast:172.16.0.95 Mask:255.255.255.224
[root@118114 ~]# iptables -t nat -vnL
Chain PREROUTING (policy ACCEPT 3 packets, 510 bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp -- eth1 * 0.0.0.0/0 172.16.0.90 tcp dpt:8080 to:10.3.0.2:5902
0 0 DNAT tcp -- eth1 * 0.0.0.0/0 172.16.0.90 tcp dpt:80 to:10.3.0.3:7001
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
0 0 SNAT tcp -- * eth0 0.0.0.0/0 10.3.0.2 tcp dpt:5902 to:10.3.0.204
0 0 SNAT tcp -- * eth0 0.0.0.0/0 10.3.0.3 tcp dpt:7001 to:10.3.0.204
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
同時開啟轉發
echo "1" > /proc/sys/net/ipv4/ip_forward