#
清除所有已设定之规则,回复到不设防状态
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X

 

#
单网卡透明代理
#A
为本机,将访问
A
80
端口重定向到
B
8080
端口
iptables -t nat -A PREROUTING -s ! B -d A -p tcp -m tcp --dport 80 -j DNAT --to B:8080
iptables -t nat -A POSTROUTING -s ! B -d B -p tcp -m tcp --dport 80 -j SNAT --to A
iptables -t nat -A POSTROUTING -s ! B -d B -p tcp -m tcp --sport 80 -j SNAT --to A