Hperformance
(usa Debian)
Enviado em 02/03/2010 - 12:50h
Galera infelizmente não funcionou, assim até saiu, mas algumas paginas deram pau, acho que é o meu script que tá errado não sei, por isso to colocando ele aqui junto com o do squid, blz, se vcs puderem me falar o que tá errado, ou como posso fazer, do jeito que tá as duas redes saem por um link e uma se comunica com a outra.
####firewall####
IPT="/sbin/iptables"
REDE="10.1.1.0/24"
REDE2="192.168.10.0/24"
# Excluindo as regras existentes
echo "Excluindo as regras existentes"
${IPT} -t filter -F
${IPT} -t filter -X
${IPT} -t nat -F
${IPT} -t nat -X
${IPT} -t mangle -F
${IPT} -t mangle -X
# Policiamentos padrao
echo "Policiamento padrao"
${IPT} -t filter -P INPUT DROP
${IPT} -t filter -P FORWARD DROP
${IPT} -t filter -P OUTPUT ACCEPT
${IPT} -t nat -P PREROUTING ACCEPT
${IPT} -t nat -P POSTROUTING ACCEPT
#Ignora respostas de ping
echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#comunicacao LAN com WAN
${IPT} -A FORWARD -i eth0 -o eth3 -j ACCEPT
${IPT} -A FORWARD -i eth3 -o eth0 -j ACCEPT
#comunicacao MAN com WAN
${IPT} -A FORWARD -i eth6 -o eth3 -j ACCEPT
${IPT} -A FORWARD -i eth3 -o eth3 -j ACCEPT
#comunicacao LAN com MAN
${IPT} -A FORWARD -i eth0 -o eth6 -j ACCEPT
${IPT} -A FORWARD -i eth6 -o eth0 -j ACCEPT
#Otimizando o proxy/firewall
${IPT} -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
${IPT} -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
${IPT} -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "Bloqueando hosts do gtalk"
#Bloqueando gtalk
#${IPT} -t nat -A POSTROUTING -s $REDE -d talk.google.com -p all -o eth3 -j DROP
#${IPT} -t nat -A POSTROUTING -s $REDE -d talkx.l.google.com -p all -o eth3 -j DROP
#bloqueando imo.im (64.13.152.67)
${IPT} -t nat -A POSTROUTING -s $REDE -d imo.im -p all -o eth3 -j DROP
echo "Bloqueando MSN"
${IPT} -I FORWARD -i eth+ -p tcp --dport 1863 -j DROP #Bloqueia o resto
${IPT} -I FORWARD -i eth+ -p tcp --dport 9666 -j DROP
#Entrada de portas
#LinQ
${IPT} -t filter -A INPUT -p tcp --dport 5222 -j ACCEPT
#HTTP
${IPT} -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
#SSH
${IPT} -t filter -A INPUT -p tcp --dport 22 -j ACCEPT
#FTP
${IPT} -t filter -A INPUT -p tcp --dport 21 -j ACCEPT
#WEBMIN
${IPT} -t filter -A INPUT -p tcp --dport 10000 -j ACCEPT
#Mysql
${IPT} -t filter -A INPUT -p tcp --dport 3306 -j ACCEPT
#NTOP
${IPT} -t filter -A INPUT -p tcp --dport 3000 -j ACCEPT
# MSN Gamming Zone
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 28800:29100 -j MASQUERADE
#cameras
#${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 82 -j MASQUERADE
#${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 4550 -j MASQUERADE
#${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 5550 -j MASQUERADE
#SSL
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 443 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 995 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 587 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 465 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE2 -p tcp -o eth3 --dport 443 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE2 -p tcp -o eth3 --dport 995 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE2 -p tcp -o eth3 --dport 587 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE2 -p tcp -o eth3 --dport 465 -j MASQUERADE
#FTP
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 21 -j MASQUERADE
#Libera todas as portas temporariamente (manter comentado)
#${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 21:65535 -j MASQUERADE
#Terminal Remoto
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 3389 -j MASQUERADE
#Pcanyware
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 5631 -j MASQUERADE
${IPT} -t nat -A POSTROUTING -s $REDE -p udp -o eth3 --dport 5631 -j MASQUERADE
#Redirecionando portas LinQ
${IPT} -t nat -A PREROUTING -s $REDE -i eth0 -p tcp --dport 5222 -j DNAT --to 10.1.1.1:5222
#Porta LinQ virtuaserver
${IPT} -t nat -A POSTROUTING -s $REDE -p tcp -o eth3 --dport 5223 -j MASQUERADE
#Tornando o proxy transparente
${IPT} -t nat -A PREROUTING -i eth+ -d ! 192.168.10.9 -p tcp --dport 80 -j REDIRECT --to-port 3128
#Aceita conexões da rede para squid
${IPT} -A INPUT -p TCP -i eth+ --dport 3128 -j ACCEPT
#Rejeita conexões desconhecidas
${IPT} -A INPUT -p TCP -i ! eth+ --dport 3128 -j DROP
# Portas liberadas para entrada
echo "Liberando entrada das portas"
#Circuito de cameras
#${IPT} -t filter -A INPUT -p tcp --dport 41900 -j ACCEPT
#Porta Apache
${IPT} -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
#flux
#${IPT} -t filter -A INPUT -p tcp --dport 49200:49300 -j ACCEPT
#curso secretaria
#${IPT} -t filter -A INPUT -p tcp --dport 32768:32769 -j ACCEPT
#${IPT} -t filter -A INPUT -p udp --dport 32768:32769 -j ACCEPT
#Porta Openfire
${IPT} -t filter -A INPUT -p tcp --dport 9090 -j ACCEPT
#Libera entrada de ICMP
${IPT} -t filter -A INPUT -p icmp -j ACCEPT
#Compartilhando internet
#LAN sai pela WAN
${IPT} -t nat -A POSTROUTING -s $REDE -o eth3 -j MASQUERADE
#MAN sai pela WAN
${IPT} -t nat -A POSTROUTING -s $REDE2 -o eth3 -j MASQUERADE
#Habilita encaminhamento de pacotes
echo "1" > /proc/sys/net/ipv4/ip_forward
# Interface local
echo "Liberando localhost"
${IPT} -t filter -A INPUT -i lo -j ACCEPT
${IPT} -t nat -A PREROUTING -i lo -j ACCEPT
${IPT} -t nat -A POSTROUTING -o lo -j ACCEPT
#configurando redirecionamentos
#Portas xxxx
#${IPT} -t filter -A INPUT -s 0.0.0.0 -p tcp --dport 2070 -j ACCEPT
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 2070 -j DNAT --to-dest 192.168.10.154
#${IPT} -t filter -A INPUT -s 0.0.0.0 -p tcp --dport 5010 -j ACCEPT
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 5010 -j DNAT --to-dest 192.168.10.154
#${IPT} -t filter -A INPUT -s 0.0.0.0 -p tcp --dport 5012 -j ACCEPT
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 5012 -j DNAT --to-dest 192.168.10.154
${IPT} -t filter -A INPUT -s 0.0.0.0 -p tcp --dport 3389 -j ACCEPT
${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 3389 -j DNAT --to-dest 192.168.10.254
${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 9900 -j DNAT --to-dest 10.1.1.10
${IPT} -t nat -A PREROUTING -i eth3 -p udp --dport 9901 -j DNAT --to-dest 10.1.1.10
#Portas xxxx
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 19911 -j DNAT --to-dest 10.1.1.14
#${IPT} -t nat -A PREROUTING -i eth3 -p udp --dport 8082 -j DNAT --to-dest 10.1.1.14
#Portas xxxx
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 9902 -j DNAT --to-dest 10.1.1.11
#${IPT} -t nat -A PREROUTING -i eth3 -p udp --dport 9903 -j DNAT --to-dest 10.1.1.11
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 9910 -j DNAT --to-dest 10.1.1.11
#Portas xxxx
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 9904 -j DNAT --to-dest 10.1.1.17
#${IPT} -t nat -A PREROUTING -i eth3 -p udp --dport 9905 -j DNAT --to-dest 10.1.1.17
#${IPT} -t nat -A PREROUTING -i eth3 -p tcp --dport 9912 -j DNAT --to-dest 10.1.1.17
echo "Fim das configuracoes do firewall"
echo "Atualizando o resolv.conf"
echo nameserver 10.1.1.2 > /etc/resolv.conf
echo nameserver 200.175.5.139 >> /etc/resolv.conf
echo nameserver 200.175.182.139 >> /etc/resolv.conf
echo "Fim do script"
####SQUID#####
# Dados da rede
acl minha_lan1 url_regex -i 10.1.1.0/255.255.255.0
acl minha_lan2 url_regex -i 192.168.10.0/255.255.255.0
# Dados do Squid
http_port 3128 transparent
visible_hostname xxxxxxxxxxxxxx
# Configuração do cache
cache_mem 512 MB
maximum_object_size_in_memory 128 KB
maximum_object_size 2048 KB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /var/cache/squid 6000 32 256
#Mensagens de erro do Squid em Português
error_directory /usr/share/squid/errors/Portuguese
# Localizacao do arquivo de log do Squid
cache_access_log /var/log/squid/access.log
# Atualização do Cache
refresh_pattern ^ftp: 15 20% 2280
refresh_pattern ^gopher: 15 20% 2280
refresh_pattern . 15 20% 22820
#IP's da rede local liberado tudo
acl ip_liberado src "/etc/squid/ip_liberado.txt"
http_access allow ip_liberado
# Regras de bloqueio (o IP x somente tem acesso ao site y)
#acl site_restrito dstdomain "/etc/squid/site_restrito"
#acl ip_restrito src "/etc/squid/ip_restrito"
#http_access deny ip_restrito !site_restrito
#IP's da rede local bloqueados
#acl ip_negado src "/etc/squid/ip_negado
#http_access deny ip_negado
# Regras de bloqueio de site ***por palavras
acl palavrass dstdom_regex "/etc/squid/palavras.txt"
http_access deny palavrass
#Regras de liberação de site por url
acl liberados url_regex -i "/etc/squid/liberados.txt"
http_access allow liberados
# Liberando lista de acessos MAC ADDERESS
acl liberados_mac arp "/etc/squid/liberados_mac.txt"
http_access allow liberados_mac
# Regras de bloqueio de sites que contem virus
acl viruss url_regex -i "/etc/squid/virus_url.txt"
http_access deny viruss
# Regras de bloqueio de site por url
acl site url_regex -i "/etc/squid/bloqueados_url.txt"
http_access deny site
acl msnfull arp "/etc/squid/msn.txt"
#acl msnfull src "/etc/squid/msn.txt"
#Bloqueio do MSN
acl iloveim url_regex -i messenger
http_access deny iloveim
acl msn url_regex -i gateway.dll
http_access deny msn !msnfull
#Sites nao passar pelo squid
acl NOCACHE url_regex "/etc/squid/direto.txt"
no_cache deny NOCACHE
# Bloqueando gtalk
acl gtalk url_regex -i mail.google.com/mail/channel/bind
http_access deny gtalk
acl blocked_ports port 5222-5223
http_access deny blocked_ports
#acl url_gtalk url_regex -i "/etc/squid/gtalk.txt"
#http_access deny url_gtalk
# Regra para bloqueio de extensões de streaming:
acl proibir_musica urlpath_regex -i \.aif$ \.aifc$ \.aiff$ \.asf$ \.asx$ \.avi$ \.au$ \.m3u$ \.med$ \.mp3$ \.m1v$ \.mp2$ \.mp2v$ \.mpa$ \.mov$ \.mpe$ \.mpg$ \.mpeg$ \.ogg$ \.pls$ \.ram$ \.ra$ \.ram$ \.snd$ \.wma$ \.wmv$ \.wvx$ \.mid$ \.midi$ \.rmi$ \.zip$ \.rar$ \.scr$
http_access deny proibir_musica
acl microsoft url_regex -i "/etc/squid/microsoft.txt"
http_access allow microsoft
# Barrar streaming de video
#acl streaming req_mime_type -i ^video/x-ms-asf$
#http_reply_access deny streaming
#acl stream req_mime_type -i ^application/octet-stream$
#acl stream req_mime_type -i application/octet-stream
#acl stream req_mime_type -i ^application/x-mplayer2$
#acl stream req_mime_type -i application/x-mplayer2
#acl stream req_mime_type -i ^application/x-oleobject$
#acl stream req_mime_type -i application/x-oleobject
#acl stream req_mime_type -i application/x-pncmd
#acl stream req_mime_type -i ^video/x-ms-asf$
#http_reply_access deny stream
# Bloqueando o youtube
#acl youtube rep_mime_type -i application/x-shockwave-flash
#http_reply_access deny youtube
# Regras de gerais
acl all src 0.0.0.0/0.0.0.0
http_access allow all
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 443 563
acl Safe_ports port 80 #http
acl Safe_ports port 25 #smtp
acl Safe_ports port 110 #pop3
acl Safe_ports port 21 #ftp
acl Safe_ports port 443 563 #https, news
acl Safe_ports port 70 #gopher
acl Safe_ports port 210 #wais
acl Safe_ports port 1025-65535 #unregistred ports
acl Safe_ports port 280 #http-mgmt
acl Safe_ports port 488 #gss-http
acl Safe_ports port 591 #filemaker
acl Safe_ports port 777 #multiling http
acl Safe_ports port 901 #swat
acl Safe_ports port 28800-29100 #msn zone.com
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access allow CONNECT !SSL_ports
# Libera para a rede local
acl redelocal src 10.1.1.0
acl redelocal2 src 192.168.10.0
http_access allow localhost
http_access allow minha_lan1
http_access allow minha_lan2
# Bloqueia acessos externos
http_access deny all
# Linha de teste para desempenho
detect_broken_pconn on
pipeline_prefetch on
# Windows update em cache
#refresh_pattern windowsupdate.com/.*\.(cab|exe|dll|msi) 10080 100% 43200 reload-into-ims
#refresh_pattern download.microsoft.com/.*\.(cab|exe|dll|msi) 10080 100% 43200 reload-into-ims
#refresh_pattern
www.microsoft.com/.*\.(cab|exe|dll|msi) 10080 100% 43200 reload-into-ims
#refresh_pattern au.download.windowsupdate.com/.*\.(cab|exe|dll|msi) 4320 100% 43200 reload-into-ims
refresh_pattern
www.update.microsoft.com/.*\.(cab|exe|dll|msi) 10080 100% 43200 reload-into-ims
refresh_pattern windowsupdate.com/.*\.(cab|exe|dll|msi) 10080 100% 43200 reload-into-ims
refresh_pattern download.microsoft.com/.*\.(cab|exe|dll|msi) 10080 100% 43200 reload-into-ims
refresh_pattern
www.microsoft.com/.*\.(cab|exe|dll|msi) 10080 100% 43200 reload-into-ims
refresh_pattern au.download.windowsupdate.com/.*\.(cab|exe|dll|msi) 4320 100% 43200 reload-into-ims