lucianopqd
(usa Ubuntu)
Enviado em 12/06/2008 - 11:55h
Dá uma olhada no meu firewall e tenta ajusta com o seu:
echo "Ativando Firewall"
echo "Ativando Dispositivos"
#-------------------------------------------------
EXTERNA=ppp+
INTERNA=eth0
REDELOCAL=192.168.1.0/255.255.255.0
echo "Ativando Módulos"
#--------------------------------------------------
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
modprobe ipt_LOG
modprobe ipt_REJECT
modprobe ipt_MASQUERADE
modprobe iptable_mangle
modprobe iptable_filter
modprobe ipt_TOS
echo "Limpando Regras"
#--------------------------------------------------
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t mangle
iptables -X -t mangle
iptables -F POSTROUTING -t nat
iptables -F PREROUTING -t nat
echo "Aplicando Regras"
#--------------------------------------------------
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
echo "Abrindo Conexão Inicial"
#--------------------------------------------------
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
echo "Aplicando Proteção contra Spoofing"
#--------------------------------------------------
for i in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo "1" > $i
done
echo "Aplicando Proteção contra Syn-flood e ataque DoS"
#--------------------------------------------------
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
echo "Aplicando Proteção contra ping da morte"
#--------------------------------------------------
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-request -j DROP
echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo "Aplicando Proteção contra ataques"
#--------------------------------------------------
iptables -A INPUT -m state --state INVALID -j DROP
echo "Aplicando Proteção contra pacotes danificados"
#--------------------------------------------------
iptables -A INPUT -p icmp -s 192.168.1.1/24 -j DROP
echo "Aplicando proteção nos pacotes TCP indesejaveis"
#---------------------------------------------------
iptables -A FORWARD -p tcp ! --syn -m state --state NEW -j LOG --log-level 6 --log-prefix "FIREWALL: NEW sem syn: "
iptables -A FORWARD -p tcp ! --syn -m state --state NEW -j DROP
echo "Bloqueando Point-to-Point"
#--------------------------------------------------
#--> AIM
iptables -A FORWARD -d login.oscar.aol.com -j DROP
#--> ICQ
iptables -A FORWARD -d login.icq.com -j DROP
#--> MSN
iptables -A FORWARD -s 0/0 -d e-messenger.net -j DROP
iptables -A FORWARD -s 0/0 -d msn2go.com -j DROP
iptables -A FORWARD -s 0/0 -d 65.54.179.228 -j DROP
iptables -A FORWARD -s 0/0 -d 65.4.13.0 -j DROP
iptables -A FORWARD -s 0/0 -d 207.46.1.6 -j DROP
iptables -A FORWARD -s 0/0 -d 207.46.1.8 -j DROP
iptables -A FORWARD -s 0/0 -d 207.46.1.11 -j DROP
iptables -A FORWARD -s 0/0 -d 207.46.1.12 -j DROP
iptables -A FORWARD -s 0/0 -d 207.46.1.14 -j DROP
iptables -A FORWARD -s 0/0 -d 207.46.1.13 -j DROP
#--> iMesh
iptables -A FORWARD -d 216.35.208.0 -j DROP
#--> WinMX
iptables -A FORWARD -d 209.61.186.0 -j DROP
iptables -A FORWARD -d 64.49.201.0 -j DROP
#--> Napigator
iptables -A FORWARD -d 209.25.178.0 -j DROP
#--> Morpheus
iptables -A FORWARD -s 0/0 -d 206.142.53.0 -j DROP
iptables -A INPUT -s 0/0 -d 206.142.53.0 -j DROP
iptables -A OUTPUT -s 0/0 -d 206.142.53.0 -j DROP
#--> Kazaa
iptables -A FORWARD -s 0/0 -d 213.248.112.0 -j DROP
iptables -A INPUT -s 0/0 -d 213.248.112.0 -j DROP
iptables -A OUTPUT -s 0/0 -d 213.248.112.0 -j DROP
#--> Audiogalaxy
iptables -A FORWARD -d 64.245.58.0 -j DROP
echo "Aceitando retorno da internet"
#--------------------------------------------------
iptables -A INPUT -i ! $INTERNA -j ACCEPT
iptables -A INPUT -i ! $EXTERNA -j ACCEPT
iptables -A FORWARD -o $INTERNA -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "Ativando roteamento"
#-------------------------------------------------
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "Ativando Squid Local"
#-------------------------------------------------
iptables -A INPUT -p tcp --dport 3128 -i $INTERNA -j ACCEPT
echo "Mascarando Roteador"
#---------------------------------------------------
iptables -t nat -A POSTROUTING -s $REDELOCAL -o $EXTERNA -j MASQUERADE
echo "Ativando Proxy Transparente"
#---------------------------------------------------
iptables -t nat -A PREROUTING -i $INTERNA -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i $INTERNA -p tcp --dport 8080 -j REDIRECT --to-port 3128
echo "Acelerando Conexão"
#--------------------------------------------------
iptables -t mangle -A OUTPUT -p tcp -j TOS --sport 80 --set-tos 0x08
iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TOS --set-tos 0x08
iptables -t mangle -A OUTPUT -p tcp -j TOS --sport 80 --set-tos 0x10
echo "Abrindo LOOPBACK"
#--------------------------------------------------
iptables -A INPUT -p tcp -s 127.0.0.1/255.0.0.0 -j ACCEPT
echo "Abrindo portas externa"
#--------------------------------------------------
iptables -A FORWARD -i $EXTERNA -p tcp --dport https -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport imap -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport imap -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport www -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport domain -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport domain -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport ftp -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport ftp-data -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport ssh -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 25 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 110 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport ntp -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport ntp -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 3389 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 3389 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 3386 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 3386 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 3456 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 3456 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 143 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 143 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 465 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 446 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 446 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 995 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 5800:5900 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 5800:5900 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 5801:5901 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 5801:5901 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport smtp -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport smtp -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport pop-3 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport pop-3 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 2631 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 2631 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 5222:5223 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 5222:5223 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 20001:20005 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 20000:20019 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 5024 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 1024 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 3306 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 82 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p tcp --dport 953 -j ACCEPT
iptables -A FORWARD -i $EXTERNA -p udp --dport 953 -j ACCEPT
echo "Abrindo portas internas"
#--------------------------------------------------
iptables -A FORWARD -i $INTERNA -p tcp --dport https -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport imap -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport imap -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport domain -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport domain -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport ftp -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport ftp-data -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport ssh -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 25 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 110 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport ntp -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport ntp -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 3389 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 3389 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 3386 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 3386 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 3456 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 3456 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 143 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 143 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 465 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 446 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 446 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 995 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 5800:5900 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 5800:5900 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 5801:5901 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 5801:5901 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 10000 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 10000 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport smtp -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport smtp -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport pop-3 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport pop-3 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 2631 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 2631 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 5222:5223 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 5222:5223 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 20001:20005 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 20000:20019 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 5024 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 1024 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 306 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 82 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p tcp --dport 953 -j ACCEPT
iptables -A FORWARD -i $INTERNA -p udp --dport 953 -j ACCEPT
echo "Liberando CAIXA"
#--------------------------------------------------
iptables -t nat -A PREROUTING -i eth0 -d internetcaixa.caixa.gov.br -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -d
www.caixa.gov.br -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -d
www1.caixa.gov.br -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -d cmt.caixa.gov.br -p tcp --dport 80 -j ACCEPT
iptables -I FORWARD -p tcp --dport 80 -s 192.168.1.0/24 -d 200.201.174.0/24 -j ACCEPT
iptables -I FORWARD -p tcp --dport 21 -d 200.201.174.207 -j ACCEPT
iptables -I FORWARD -p tcp --dport 80 -d 200.201.174.207 -j ACCEPT
iptables -I FORWARD -p tcp --dport 20001:20005 -s 200.201.174.207 -j ACCEPT
iptables -I FORWARD -p tcp --dport 20000:20019 -d 200.201.174.207 -j ACCEPT
iptables -I FORWARD -p tcp -s 200.201.174.207 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -I PREROUTING -d 200.201.174.207 -j ACCEPT
iptables -t nat -I PREROUTING -s 200.201.174.207 -j ACCEPT
iptables -A INPUT -i eth1 -p udp -s 200.201.174.201 -j ACCEPT
iptables -A INPUT -i eth0 -p udp -s 200.201.174.201 -j ACCEPT
iptables -A OUTPUT -p tcp --destination-port 2631:2631 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 2631:2631 -j ACCEPT
echo "Trocando Portas"
#--------------------------------------------------
PORT_INI=61000
PORT_FIM=65095
echo $PORT_INI $PORT_FIM > /proc/sys/net/ipv4/ip_local_port_range
echo "Bloqueando pocotes não liberados"
#---------------------------------------------------
iptables -A FORWARD -j DROP
iptables -A INPUT -j DROP
echo
echo "Firewall Ativo!"