通过 iptables 实现 SNAT&DNAT (浮动IP)
模拟环境IP信息
内网IP | 外网IP |
---|---|
172.168.128.10 | 192.168.128.77 |
设置
iptables -t nat -I POSTROUTING -s 172.168.128.10 -j SNAT --to-source 192.168.128.77
iptables -t nat -I PREROUTING -d 192.168.128.77 -j DNAT --to-destination 172.168.128.10
service iptables save
service iptables restart
取消设置
iptables -t nat -D POSTROUTING -s 172.168.128.10 -j SNAT --to-source 192.168.128.77
iptables -t nat -D PREROUTING -d 192.168.128.77 -j DNAT --to-destination 172.168.128.10
service iptables save
service iptables restart
评论(0)