2019年6月21日

iptables 內部簡易 NAT

#!/bin/bash
#PATH=/sbin:/bin:/usr/sbin:/usr/bin; export PATH
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -Z
iptables -P INPUT   ACCEPT
iptables -P OUTPUT  ACCEPT
iptables -P FORWARD ACCEPT
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -t nat -P PREROUTING  ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT      ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.228.0/24 -o eth1 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth1 -s 192.168.228.0/24 -p tcp --dport 80 -j REDIRECT --to-ports 3128
/etc/init.d/iptables save
/etc/init.d/iptables restart
 

沒有留言: