iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X
iptables -P INPUT ACCETP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
echo 1>/proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT - - to 208.216.201.144
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
service iptables save
iptables -t nat -A PROROUTING -i eth0 -p tcp - -dport 80 -j REDIRECT - -to-ports 3128
iptables -A POSTROUTING -t nat -s 192.168.1.0/24 -o eth0 -j SNAT --to-source 218.206.201.44
这一条最好是更改配置文件,/etc/sysctl.conf把ip_forward的值改为1才是最稳定的
发布网内web服务器
iptables -t nat -A PREROUTING -d [url]www.example.com[/url] -p tcp --dport 80 -j DNAT - - to-dest 192.168.0.10