iptables双网卡配置nat

eth0 192.168.0.55
eth1 192.168.0.56
eth2 10.22.0.55
eth3 10.22.0.56

配置内核允许nat转发

echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf

sysctl -p

清空iptables策略

iptables -F

配置转发

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth2 -j SNAT –to-source 10.22.0.55

iptables -t nat -A POSTROUTING -s 10.22.0.0/24 -o eth0 -j SNAT –to-source 192.168.0.55

测试成功后保存策略并重启防火墙

service iptables save

service iptables restart