iptables 实现两个网卡端口转发

Posted on Posted in iptables

流程

client0 -> eth0 -> eth1 -> client1

网卡IP端口
eth01.2.3.481
eth1192.68.0.1
client06.7.8.91080
client1192.168.0.28180
iptables -t nat -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 81 -j DNAT --to-destination 192.168.0.2:8180
iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -d 192.168.0.2 -p tcp -m tcp --dport 8180 -j SNAT --to-source 192.168.0.1
iptables -A INPUT -d 192.168.0.2 -p tcp -m tcp --dport 8180 -i eth0 -j ACCEP

Leave a Reply

Your email address will not be published. Required fields are marked *

four − 4 =