sebuba
(usa Ubuntu)
Enviado em 05/01/2010 - 11:43h
Olá pessoal, tenho um servidor Ubuntu Server, praticamente configurado, msn-proxy funcionando, sarg funcionando, squid transparente funcionando, ntop funcionando, thunder-cache funcionando, imspector funcionando, praticamente tudo. Porém o L7-FILTER não, já compilei o kernel, o módulo modprobe xt_layer7 também carrega sem problema. Consigo executar o comando iptables -A OUTPUT -m layer7 --l7proto bittorrent -j DROP , não apresenta nenhum erro. Mas ao fazer o teste, meu Transmission (torrent ubuntu) fuciona perfeitamente, nada é bloqueado, nem mesmo o emule consegui bloquear. Segue meu iptables:
# Regras do iptables
#
# Interface da Internet:
ifinternet="eth0"
# Interface da rede local
iflocal="eth1"
# Interface da
#iflocal="eth2"
# Desabilita eth2
ifconfig eth2 down
# Ativa módulos
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ipt_LOG
modprobe ipt_REJECT
modprobe ipt_MASQUERADE
modprobe x_tables
modprobe xt_layer7
#insmod ipt_ipp2p.ko
# Limpa as regras existentes
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter
# Regras para o funcionamento do proxy
iptables -t nat -A PREROUTING -i $iflocal -p tcp --dport 1863 -j REDIRECT --to-port 1863
iptables -t nat -A PREROUTING -i $iflocal -p udp --dport 1863 -j REDIRECT --to-port 1863
iptables -t nat -A PREROUTING -i $iflocal -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A POSTROUTING -o $ifinternet -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
# Proteção contra spoofing
# Descarta pacotes mal formados
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
iptables -A INPUT -m state --state INVALID -j DROP
# Proteção contra trinoo
iptables -N TRINOO
iptables -A TRINOO -m limit --limit 15/m -j LOG --log-level 6 --log-prefix "FIREWALL: trinoo: "
iptables -A TRINOO -j DROP
iptables -A INPUT -p TCP -i $ifinternet --dport 27444 -j TRINOO
iptables -A INPUT -p TCP -i $ifinternet --dport 27665 -j TRINOO
iptables -A INPUT -p TCP -i $ifinternet --dport 31334 -j TRINOO
iptables -A INPUT -p TCP -i $ifinternet --dport 34555 -j TRINOO
iptables -A INPUT -p TCP -i $ifinternet --dport 35555 -j TRINOO
# Proteção contra tronjans
iptables -N TROJAN
iptables -A TROJAN -m limit --limit 15/m -j LOG --log-level 6 --log-prefix "FIREWALL: trojan: "
iptables -A TROJAN -j DROP
iptables -A INPUT -p TCP -i $ifinternet --dport 666 -j TROJAN
iptables -A INPUT -p TCP -i $ifinternet --dport 666 -j TROJAN
iptables -A INPUT -p TCP -i $ifinternet --dport 4000 -j TROJAN
iptables -A INPUT -p TCP -i $ifinternet --dport 6000 -j TROJAN
iptables -A INPUT -p TCP -i $ifinternet --dport 6006 -j TROJAN
iptables -A INPUT -p TCP -i $ifinternet --dport 16660 -j TROJAN
# Proteção contra worms
iptables -A FORWARD -p tcp --dport 135 -i $iflocal -j REJECT
# Proteção contra syn-flood
iptables -A FORWARD -p tcp --syn -m limit --limit 2/s -j ACCEPT
# Proteção contra ping da morte
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
# Proteção contra port scanners
iptables -N SCANNER
iptables -A SCANNER -m limit --limit 15/m -j LOG --log-level 6 --log-prefix "FIREWALL: port scanner: "
iptables -A SCANNER -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -i $ifinternet -j SCANNER
iptables -A INPUT -p tcp --tcp-flags ALL NONE -i $ifinternet -j SCANNER
iptables -A INPUT -p tcp --tcp-flags ALL ALL -i $ifinternet -j SCANNER
iptables -A INPUT -p tcp --tcp-flags ALL FIN,SYN -i $ifinternet -j SCANNER
iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -i $ifinternet -j SCANNER
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -i $ifinternet -j SCANNER
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -i $ifinternet -j SCANNER
# MSN:
#iptables -t nat -A PREROUTING -p tcp --destination-port 1863 -j REDIRECT --to-ports 16667
# Jabber:
iptables -t nat -A PREROUTING -p tcp --destination-port 5222 -j REDIRECT --to-ports 16667
# Jabber over SSL:
iptables -t nat -A PREROUTING -p tcp --destination-port 5223 -j REDIRECT --to-ports 16667
# ICQ/AIM:
iptables -t nat -A PREROUTING -p tcp --destination-port 5190 -j REDIRECT --to-ports 16667
# Yahoo:
iptables -t nat -A PREROUTING -p tcp --destination-port 5050 -j REDIRECT --to-ports 16667
# IRC:
iptables -t nat -A PREROUTING -p tcp --destination-port 6667 -j REDIRECT --to-ports 16667
# Gadu-Gadu:
iptables -t nat -A PREROUTING -p tcp --destination-port 8074 -j REDIRECT --to-ports 16667
# Bloqueia gtalk no gmail.com
#iptables -I INPUT -s talk.google.com -j DROP
#iptables -A OUTPUT -d talk.google.com -j DROP
#iptables -I FORWARD -s 0/0 -d talk.google.com -j DROP
iptables -I INPUT -s chatenabled.mail.google.com -j DROP
iptables -A OUTPUT -d chatenabled.mail.google.com -j DROP
iptables -I FORWARD -s 0/0 -d chatenabled.mail.google.com -j DROP
# Bloqueio P2P
iptables -A OUTPUT -m layer7 --l7proto bittorrent -j DROP
iptables -A INPUT -m layer7 --l7proto bittorrent -j DROP
iptables -A INPUT -m layer7 --l7proto tor -j DROP
iptables -A OUTPUT -m layer7 --l7proto tor -j DROP
iptables -A INPUT -m layer7 --l7proto 100bao -j DROP
iptables -A OUTPUT -m layer7 --l7proto 100bao -j DROP
iptables -A INPUT -m layer7 --l7proto applejuice -j DROP
iptables -A INPUT -m layer7 --l7proto ares -j DROP
iptables -A INPUT -m layer7 --l7proto directconnect -j DROP
iptables -A INPUT -m layer7 --l7proto edonkey -j DROP
iptables -A OUTPUT -m layer7 --l7proto edonkey -j DROP
iptables -A INPUT -m layer7 --l7proto fasttrack -j DROP
iptables -A INPUT -m layer7 --l7proto gnucleuslan -j DROP
iptables -A INPUT -m layer7 --l7proto gnutella -j DROP
iptables -A INPUT -m layer7 --l7proto goboogy -j DROP
iptables -A INPUT -m layer7 --l7proto hotline -j DROP
iptables -A INPUT -m layer7 --l7proto imesh -j DROP
iptables -A INPUT -m layer7 --l7proto kugoo -j DROP
iptables -A INPUT -m layer7 --l7proto mute -j DROP
iptables -A INPUT -m layer7 --l7proto napster -j DROP
iptables -A INPUT -m layer7 --l7proto openft -j DROP
iptables -A INPUT -m layer7 --l7proto poco -j DROP
iptables -A INPUT -m layer7 --l7proto pplive -j DROP
iptables -A INPUT -m layer7 --l7proto soribada -j DROP
iptables -A INPUT -m layer7 --l7proto soulseek -j DROP
iptables -A INPUT -m layer7 --l7proto tesla -j DROP
iptables -A INPUT -m layer7 --l7proto thecircle -j DROP