# allow ping from internet iptables -A INPUT -i $EXT_IF -p icmp -j ACCEPT
# enable local traffic #------------------------------------------------------------------------ # iptables -A INPUT ! -i $EXT_IF -m state --state NEW -j ACCEPT # iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # # iptables -A FORWARD ! -i $EXT_IF -m state --state NEW -j ACCEPT # iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT #------------------------------------------------------------------------
iptables -N allowed iptables -A allowed ! -i $EXT_IF -m state --state NEW -j ACCEPT iptables -A allowed -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -j allowed iptables -A FORWARD -j allowed
for PORT in $TRUSTED_LOCAL_TCP_PORT; do iptables -A INPUT -i $EXT_IF -p tcp --dport $PORT -m state --state NEW -j ACCEPT
done
for PORT in $TRUSTED_LOCAL_UDP_PORT; do iptables -A INPUT -i $EXT_IF -p udp --dport $PORT -m state --state NEW -j ACCEPT
done
#---------------------- nat ---------------------
# port forwarding for PORT in $FWD_TCP_PORT; do iptables -A FORWARD -i $EXT_IF -o $INT_IF -d $SERVER_IP -p tcp --dport $PORT -m state --state NEW -j ACCEPT iptables -t nat -A PREROUTING -d $EXT_IP -p tcp --dport $PORT -j DNAT --to-destination $SERVER_IP iptables -t nat -A POSTROUTING -d $SERVER_IP -p tcp --dport $PORT -j SNAT --to-source $INT_IP done
for PORT in $FWD_UDP_PORT; do iptables -A FORWARD -i $EXT_IF -o $INT_IF -d $SERVER_IP -p udp --dport $PORT -m state --state NEW -j ACCEPT iptables -t nat -A PREROUTING -d $EXT_IP -p udp --dport $PORT -j DNAT --to-destination $SERVER_IP iptables -t nat -A POSTROUTING -d $SERVER_IP -p udp --dport $PORT -j SNAT --to-source $INT_IP done
# Transparent Proxy iptables -t nat -A PREROUTING -i $INT_IF -p tcp --dport 80 -j REDIRECT --to- port 3128
# SNAT or MASQUERADE #------------------------------------------------------------------------ # iptables -t nat -A POSTROUTING -o $EXT_IF -j SNAT --to-source $EXT_IP #------------------------------------------------------------------------ iptables -t nat -A POSTROUTING -o $EXT_IF -j MASQUERADE