magnolinux
(usa Debian)
Enviado em 15/01/2009 - 08:48h
Vou colocar aqui como estao minha regras no firewall. se possivel analisarem, e me reportarem os erros.. grato.
#!/bin/bash
echo "Ativando Firewall..."
# Limpando Tabelas
iptables -F
iptables -t filter -F
iptables -t nat -F
iptables -t mangle -F
# Politica padrao
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# Tabela NAT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
#Tabela mangle
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
# Aceitar Pacotes Estabilziados
iptables -t filter -A INPUT -m state --state ESTABLISHED -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED -j ACCEPT
# Carregando Modulos
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
modprobe ip_conntrack
modprobe iptable_filter
modprobe iptable_nat
modprobe ipt_state
modprobe ipt_limit
modprobe ipt_LOG
modprobe ipt_MASQUERADE
# Bloqueando MSN
iptables -A FORWARD -d 64.4.13.0/24 -j REJECT
iptables -A FORWARD -s 0/0 -p tcp --dport 1863 -j REJECT
iptables -A FORWARD -s 0/0 -d 207.46.104.20 -j REJECT
# Rede_Interna
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 1863 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -d loginnet.passport.com -j ACCEPT
# Desabilita resposta para ping
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
# Desabilita port scan
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
# Desabilita redirecionamento de ICMP
for f in /proc/sys/net/ipv4/conf/*/accept_redirects; do
echo 0 >$f
done
# Protecao contra IP spoofing
for i in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo 1 >$i
done
# Protecao contra synflood
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
# Ativando protecao contra responses bogus
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
# Protecao contra worms
iptables -A FORWARD -p tcp --dport 135 -j DROP
iptables -A INPUT -p tcp --dport 135 -j DROP
# Descarte de pacotes nao identificados ICMP
iptables -A OUTPUT -m state -p icmp --state INVALID -j DROP
iptables -A INPUT -m state -p icmp --state INVALID -j DROP
iptables -A FORWARD -m state -p icmp --state INVALID -j DROP
# Impedindo ataque Ping of Death
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
# Impedindo ataque de Denial Of Service -DOS-
iptables -A FORWARD -p tcp -m limit --limit 1/s -j ACCEPT
# Impedindo ataque Port Scanners
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD --protocol tcp --tcp-flags ALL SYN,ACK -j DROP
# Bloqueia traceroute
iptables -A INPUT -p udp --dport 33435:33525 -j DROP
# Bloquear Back Orifice:
iptables -A INPUT -p tcp --dport 31337 -j DROP
iptables -A INPUT -p udp --dport 31337 -j DROP
# Bloquear NetBus:
iptables -A INPUT -p tcp --dport 12345:12346 -j DROP
iptables -A INPUT -p udp --dport 12345:12346 -j DROP
# Libera Trafego Local
iptables -A INPUT -i lo -j ACCEPT
# Abrindo http e https
iptables -t filter -A FORWARD -p tcp --dport 80 -j ACCEPT
iptables -t filter -A FORWARD -p tcp --dport 443 -j ACCEPT
# "Bloqueando o LogMeIn"
iptables -t filter -A FORWARD -p tcp --dport 2002 -j DROP
iptables -t filter -A FORWARD -d 69.209.251.0/24 -j DROP
iptables -t filter -A FORWARD -s 69.209.251.0/24 -j DROP
# Bloqueando Samba para acesso externo
iptables -t filter -A INPUT -p tcp --dport 137 -j DROP
iptables -t filter -A INPUT -p tcp --dport 138 -j DROP
iptables -t filter -A INPUT -p tcp --dport 139 -j DROP
# Liberando Conexao OPENVPN
#iptables -t filter -A INPUT -p udp --dport 5555 -j ACCEPT
#iptables -t filter -A FORWARD -p udp --dport 5555 -j ACCEPT
# Liberando TEDSEF
iptables -t filter -A FORWARD -p tcp -i eth1 -d 200.199.34.41 -j ACCEPT
# Liberando Sintegra
iptables -t filter -A FORWARD -p tcp -i eth1 --dport 8017 -j ACCEPT
# Liberando a atualizacao do Ad-ware
iptables -t filter -A FORWARD -s 192.168.0.0/24 -d 82.99.19.14/28 -p tcp --dport 80 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.0.0/24 -d 207.44.136.40 -p tcp --dport 80 -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.0.0/24 -d 72.246.49.42/27 -p tcp --dport 80 -j ACCEPT
# Liberando acesso a servidor Apache.
#iptables -t filter -A INPUT -i ppp0 -p tcp -s 0/0 --sport 8080 -j ACCEPT
#iptables -t filter -A INPUT -i ppp0 -p tcp -s 0/0 --dport 8080 -j ACCEPT
#iptables -t filter -A INPUT -i ppp0 -p tcp -s 0/0 --sport 80 -j ACCEPT
#iptables -t filter -A INPUT -i ppp0 -p tcp -s 0/0 --dport 80 -j ACCEPT
# Liberando consulta em servidor de Dns.
#iptables -t filter -A INPUT -i ppp0 -p tcp -s 0/0 --sport 53 -j ACCEPT
#iptables -t filter -A INPUT -i eth0 -p tcp -s 0/0 --sport 53 -j ACCEPT
# Liberando Acesso FTP
#iptables -t filter -A INPUT -i ppp0 -p tcp -s 0/0 --dport 8660 -j DROP
#iptables -t filter -A INPUT -i eth1 -p tcp -s 0/0 --dport 8660 -j ACCEPT
#iptables -t filter -A INPUT -i eth2 -p tcp -s 0/0 --dport 8660 -j ACCEPT
#iptables -t filter -A INPUT -i eth3 -p tcp -s 0/0 --dport 8660 -j ACCEPT
# Libera acesso EXTERNO para SSH
# SSH Mac Address
#iptables -A INPUT -i ppp0 -m mac --mac-source 02:00:4C:4F:4F:50 -p tcp --dport 9999 -j ACCEPT
iptables -t filter -A INPUT -i ppp0 -p tcp -s 0/0 --dport 9999 -j ACCEPT
iptables -t filter -A INPUT -i eth0 -p tcp -s 0/0 --dport 9999 -j DROP
iptables -t filter -A INPUT -i eth1 -p tcp -s 0/0 --dport 9999 -j ACCEPT
# Liberando smtp e pop
#iptables -t filter -A INPUT -p tcp --dport 110 -j ACCEPT
#iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 110 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
iptables -t filter -A FORWARD -p tcp -s 0/0 -d 0/0 --dport 25 -j ACCEPT
iptables -t filter -A FORWARD -p tcp -s 0/0 -d 0/0 --dport 110 -j ACCEPT
# Liberando conexao cmt.caixa.gov.br
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp -d cmt.caixa.gov.br --dport 80 -j RETURN
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp -d 200.201.174.0/24 --dport 80 -j RETURN
# Liberando Conectividade Social
iptables -t nat -A PREROUTING -i eth1 -p tcp -d 200.255.42.71 --dport 80 -j ACCEPT
# Sefip / CNS
iptables -t nat -A PREROUTING -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -A FORWARD -p tcp -d 200.201.0.0/16 -j ACCEPT
# Programa Boleto sicoob
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp -d 200.252.146.0/24 --dport 80 -j RETURN
# Redirecionando Acesso remoto via Terminal Server
#iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 3389 -j DNAT --to-destination 129.12.70.110:3389
#iptables -t nat -A PREROUTING -p udp -i ppp0 --dport 3389 -j DNAT --to-destination 129.12.70.110:3389
#iptables -A INPUT -p tcp -i ppp0 -s 0/0 --dport 3389 --syn -j ACCEPT
# Redirecionamento da porta 1435 para acesso remoto do SQL
#iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 1435 -j DNAT --to-destination 129.12.70.110:1435
#iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 1433 -j DNAT --to-destination 129.12.70.110:1433
# Redirecionando acesso porta 5900 (VNC) para micro da rede local
#iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 5900 -j DNAT --to-destination 10.6.0.2:5900
# Priorizando tráfego na porta 80
#iptables -t mangle -A INPUT -p tcp --dport 80 -j TOS --set-tos 16
# Bloqueando Emule
iptables -A FORWARD -p tcp -m multiport --dport 4661,4711,4662,4665,4672 -j DROP
iptables -A FORWARD -p udp -m multiport --dport 4662,4672,4665 -j DROP
# Bloqueando IMesh
iptables -A FORWARD -d 216.35.208.0/24 -j DROP
# Bloqueando Bearshare
iptables -A FORWARD -p tcp --dport 6346 -j DROP
# Bloqueando ToadNode
iptables -A FORWARD -p tcp --dport 6346 -j DROP
# Bloqueando WinMX
iptables -A FORWARD -d 209.61.186.0/24 -j DROP
iptables -A FORWARD -d 64.49.201.0/24 -j DROP
# Bloqueando Napigator
iptables -A FORWARD -d 209.25.178.0/24 -j DROP
# Bloqueando Morpheus
iptables -A FORWARD -d 206.142.53.0/24 -j DROP
iptables -A FORWARD -p tcp --dport 1214 -j DROP
# Bloqueando KaZaA
iptables -A FORWARD -d 213.248.112.0/24 -j DROP
iptables -A FORWARD -p tcp --dport 1214 -j DROP
# Bloqueando Limewire
iptables -A FORWARD -p tcp --dport 6346 -j DROP
# Bloqueando Audiogalaxy
iptables -A FORWARD -d 64.245.58.0/23 -j DROP
# Bloqueando AIM
iptables -A FORWARD -p tcp --dport 5190 -j DROP
iptables -A FORWARD -d 64.12.161.153/24 -j DROP
# Bloqueando ICQ
iptables -A FORWARD -p tcp --dport 5190 -j DROP
iptables -A FORWARD -d 205.188.153.121/24 -j DROP
# Bloqueando Yahoo Messenger
iptables -A FORWARD -d 216.136.233.138/24 -j DROP
# Bloqueando Napster
iptables -A FORWARD -d 64.124.41.0/24 -j DROP
# Bloqueando Bittorent
iptables -A FORWARD -p tcp --dport 6881:6889 -j DROP
iptables -A FORWARD -p tcp --dport 6881:6889 -j DROP
# Redirecionando Porta 80 para 3128
#iptables -t nat -A PREROUTING -p tcp -m multiport --dport 80,443 -j REDIRECT --to-port 3128
# roteando velox para rede
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE
# ativando Roteamento no kernel
echo 1 > /proc/sys/net/ipv4/ip_forward
# Libera ADSL Velox para toda Rede
iptables -A FORWARD -i ppp0 -j ACCEPT
# Liberando trafego para Rede Interna
iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A OUTPUT -s 192.168.0.0/24 -j ACCEPT
echo "Reagras Adicionadas..."
vlw galera... fico aguardando o post mostrando os erros no firewall