# FIREWALL - COMPARTILHANDO A INTERNET COM TUDO LIBERADO #
#!/bin/bash
echo " Ativa roteamento de pacotes........................... [ OK ]"
echo 1 > /proc/sys/net/ipv4/ip_forward
echo " Declarando variaveis.................................. [ OK ]"
IPT="/sbin/iptables"
EXT_IF="eth0" # Interface Internet
INT_IF="eth1" # Interface Rede Local
EXT_IP="192.168.100.220" # IP da Internet
INT_IP="10.1.1.1" # IP da Rede Local
INT_NET="10.1.1.0/255.255.255.0" # Range da Rede Local
EXT_NET="192.168.100.0/255.255.255.0" # Range do IP da Internet
echo " Limpando regras....................................... [ OK ]."
$IPT -F -v
$IPT -F -t nat -v
$IPT -F -t mangle -v
$IPT -X -v
$IPT -X -t nat -v
$IPT -X -t mangle -v
$IPT -Z -v
$IPT -Z -t nat -v
$IPT -Z -t mangle -v
echo " Definindo Regras Padrao............................... [ OK ]"
$IPT -P INPUT ACCEPT -v
$IPT -P FORWARD ACCEPT -v
$IPT -P OUTPUT ACCEPT -v
echo " Libera tudo........................................... [ OK ]"
$IPT -A INPUT -i $INT_IF -j ACCEPT -v
$IPT -A FORWARD -i $INT_IF -j ACCEPT -v
$IPT -A INPUT -i $EXT_IF -j ACCEPT -v
$IPT -A FORWARD -i $EXT_IF -j ACCEPT -v
echo " Compartilha a internet com a Rede Interna............. [ OK ] "
$IPT -t nat -A POSTROUTING -o $EXT_IF -s $INT_NET -j SNAT --to-source $EXT_IP -v
echo " Pronto "