LeonardoKadina
(usa Ubuntu)
Enviado em 22/09/2009 - 12:19h
E tbm o meu Iptables.
#! /bin/bash
clear
echo "Modulos carreagdos"
#Carregar moduloss
modprobe iptable_nat
modprobe ip_tables
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe iptable_filter
modprobe iptable_mangle
modprobe ipt_LOG
modprobe ip_gre
modprobe ipt_MASQUERADE
modprobe ip_nat
modprobe ip_nat_ftp
printf "Limpando tabelas e setando variaveis do kernel.. \n"
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
printf "*****************************ok********************************* \n"
#Definir regras
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
echo "Regras definidas."
printf "*****************************ok********************************* \n"
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
printf "*****************************ABRINDO FAIXA DE IP********************************* \n"
# Abre a faixa de ip.
iptables -A INPUT -s IP_da_Rede/255.255.255.0 -j ACCEPT
printf "*****************************ok********************************* \n"
printf "*****************************CRIANDO MASQUERADE********************************* \n"
#cria um masquerade.
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
printf "*****************************ok********************************* \n"
printf "*****************************ABRINDO PORTAS 22, 21 e 80********************************* \n"
# Abre a 22 e 21 porta (inclusive para a Internet):
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
printf "*****************************ok********************************* \n"
printf "*****************************NET********************************* \n"
# net
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
printf "*****************************ok********************************* \n"
printf "*****************************IGNORANDO PINGS********************************* \n"
# Ignora pings.
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
printf "*****************************ok********************************* \n"
printf "*****************************Impedindo pacotes mal formados********************************* \n"
# Impede pacotes mal formados
iptables -A INPUT -m state --state INVALID -j DROP
printf "*****************************ok********************************* \n"
printf "*****************************Abrindo Trafego interno********************************* \n"
# Abre o trafego interno
iptables -A INPUT -i lo -j ACCEPT
printf "*****************************ok********************************* \n"
printf "*****************************Iniciando Proxy Transparente********************************* \n"
#Proxy transparente.
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
#iptables -t nat -A PREROUTING -i eth0 -d 192.168.1.11 -p tcp --sport 2000 -j REDIRECT --to-port 2000
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2000 -j DNAT --to 192.168.1.11
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3389 -j DNAT --to 192.168.1.11
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5550 -j DNAT --to 192.168.1.11
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 4550 -j DNAT --to 192.168.1.11
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3550 -j DNAT --to 192.168.1.11
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 200 -j DNAT --to 192.168.1.11
printf "*****************************ok********************************* \n"
printf "*****************************Iniciando Regras FORWARD********************************* \n"
#Regras FORWARD.
iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 3128 -j ACCEPT
iptables -A FORWARD -p udp -i eth1 -s IP_da_Rede/24 --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 8080 -j ACCEPT
iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 149 -j ACCEPT
iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 25 -j ACCEPT
iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 443 -j ACCEPT
#iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 2000 -j ACCEPT #Camera
#iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 3550 -j ACCEPT #Camera
#iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 4550 -j ACCEPT #Camera
#iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 5550 -j ACCEPT #Camera
#iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 3389 -j ACCEPT #Terminal Server Servidor de Camera
#iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 200 -j ACCEPT #Camera
#iptables -A FORWARD -p tcp -i eth1 -s IP_da_Rede/24 --dport 587 -j ACCEPT #SMTP Art- vide
printf "*****************************DROPS********************************* \n"
iptables -A FORWARD -p udp -i eth1 -j DROP
iptables -A FORWARD -p tcp -i eth1 -j DROP
printf "*****************************FIM********************************* \n"