xlinux
(usa Ubuntu)
Enviado em 28/05/2015 - 11:07h
Bom dia obrigado por responder.
Minha rede está assim: modem/roteador > proxy/firewall > switch > server 2012
Squid
#Squid.conf
#Autenticacao
auth_param basic children 5
auth_param basic credentialsttl 2 hours
authenticate_cache_garbage_interval 10 minutes
authenticate_ttl 10 minutes
authenticate_ip_ttl 0 seconds
auth_param basic realm Autenticador, Digite seu Login e Senha.
auth_param basic children 5
auth_param basic program /usr/lib/squid3/ncsa_auth /etc/shadow
#http_port 3128 transparent
http_port 192.168.1.250:3128
visible_hostname atenas
error_directory /usr/share/squid3/errors/Portuguese
#Diretorio do cache
cache_dir ufs /var/cache/squid3 4096 16 256
#Log
cache_access_log /var/log/squid3/access.log
#Porcentagem de atualizacao do cache -limpo ao atingir o maximo
cache_swap_low 85
cache_swap_high 90
#Memoria do cache
cache_mem 512 MB
#Usar o maximo de memoria possivel
memory_pools on
memory_pools_limit 2048 MB
#Tamanho maximo de arquivos alocados na RAM
maximum_object_size_in_memory 2048 KB
maximum_object_size 4096 KB
#Maximo e Minimo armazenados no disco
maximum_object_size 512 MB
minimum_object_size 0 KB
# Portas Liberadas
acl SSL_ports port 443
acl SSL_ports port 10000 # Webmin HTTPS
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered 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 10000 # Webmin
acl Safe_ports port 3306 # Cartago
acl Safe_ports port 82 # conectividade digital
acl Safe_ports port 81 # conectividade digital
acl Safe_ports port 3443 # Sped receita federal
acl Safe_ports port 3337 # Sped
acl Safe_ports port 3338 # Sped
http_access deny !Safe_ports
# ACL PARA CONEXAO METODO SSL
acl CONNECT method CONNECT
http_access deny CONNECT !SSL_ports
#ACLs para cep
#acl cep dstdomain "etc/squid3/cep"
#http_access allow cep
# ACLs PARA SITES LIBERADOS
acl sites_liberados url_regex -i "/etc/squid3/sites_liberados"
http_access allow sites_liberados
#ACLs PARA IP LIBERADO
acl ip_liberado src "/etc/squid3/ip_liberado"
http_access allow ip_liberado
# ACLs PARA SITES BLOQUEADOS
acl sites_bloqueados url_regex -i "/etc/squid3/bloqueados"
http_access deny sites_bloqueados
#ACLs PARA SITES
#acl sites_porno url_regex -i "etc/squid3/<span class='filtrado'>[*****]</span>"
#http_access deny sites_porno
#ACL PARA BLOQUEAR PROXY ANONIMO
#acl sites_proxy url_regex -i "etc/squid3/proxy"
#http_access deny sites_proxy
#ACL PARA BLOQUEIO DE SPYWARES
#acl sites_spywares url_regex -i "etc/squid3/spywares"
#http_access deny sites_spywares
#ACL PARA BLOQUEIO EM BLOG E CHAT
acl sites_blogchat url_regex -i "/etc/squid3/blogchat"
http_access deny sites_blogchat
#ACL PARA BLOQUEIO DE MUSICAS
#acl sites_musicas url_regex -i "etc/squid3/musicas"
#http_access deny sites_musicas
#ACL STREAMING DE AUDIO E VIDEO
acl streaming req_mime_type ^video/x-ms-asf
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$
http_access deny proibir_musica
http_reply_access deny streaming
#DNS PARA A REDE
dns_nameservers 192.168.1.250
acl localnet src 192.168.1.0/24
#CONTROLE DE BANDA
acl liberado src "/etc/squid3/liberado"
acl limitado src "/etc/squid3/limitado"
delay_pools 2
delay_class 1 2
delay_parameters 1 -1/-1 -1/-1
delay_access 1 allow liberado
delay_class 2 2
delay_parameters 2 1280000/1280000 1280000/1280000
delay_access 2 allow limitado
# Politicas para rede local
http_access allow localnet
http_access deny all
Firewall
#!/bin/bash
#Limpa todas as regras
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -F
# Cria regra default para Chains
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
# Carrega modulos do iptables
modprobe ip_tables
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ipt_string
echo 0 > /proc/sys/net/ipv4/conf/all/log_martians
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
# Libera Rede Interna
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
# Libera Logmein
iptables -A FORWARD -i eth1 -p tcp -d 216.52.233.0/24 --dport 443 -j ACCEPT
#Bloqueia a porta 80 pra toda rede como no exemplo abaixo:
# Bloqueio da Porta 80 TCP
iptables -A FORWARD -p tcp --destination-port 80 -s 192.168.1.0/24 -j DROP
#iptables -A FORWARD -p tcp --destination-port 443 -s 192.168.1.0/24 -j DROP
#iptables -A FORWARD -p tcp --destination-port 445 -s 192.168.1.0/24 -j DROP
#iptables -A FORWARD -p udp --destination-port 137 -s 192.168.1.0/24 -j DROP
#iptables -A FORWARD -p udp --destination-port 138 -s 192.168.1.0/24 -j DROP
#iptables -A FORWARD -p udp --destination-port 139 -s 192.168.1.0/24 -j DROP
#iptables -t nat -A PREROUTING -p tcp -i eth1 -p tcp --dport 80 -j REDIRECT --to port 3128
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
#iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 443 -j REDIRECT --to-port 3128
iptables -A FORWARD -t filter -j ACCEPT
iptables -A FORWARD -t filter -j ACCEPT -m state --state ESTABLISHED,RELATED,NEW
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#LIBERA DNS SERVER PARA A REDE
iptables -A INPUT -p tcp -s 192.168.1.4 --sport 53 -d 192.168.1.0/24 -j ACCEPT
# LIBERA PORTA PARA CAMERA
iptables -t nat -A PREROUTING -j DNAT --to 192.168.0.191 -i eth0 -d 192.168.1.9 -p tcp --dport 7000
iptables -A FORWARD -j ACCEPT -i eth0 -o eth1 -s 0/0 -d 192.168.1.191 -p tcp --dport 7000
# Bloqueio ultra-surf
iptables -A FORWARD -p tcp -d 65.49.2.0/24 -j DROP
iptables -A FORWARD -p tcp -d 65.49.14.0/24 -j DROP
iptables -A FORWARD -p tcp --dport 19769 -j DROP
##PROTECOES
#PROTEGE CONTRA OS "PING OF DEATH"
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 20/m -j REJECT
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 20/m -j REJECT
# Protege contra port scanners avan?ados (Ex.: nmap)
iptables -A INPUT -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 20/m -j ACCEPT
# Bloqueando tracertroute
iptables -A INPUT -p udp -s 0/0 -i eth0 --dport 33435:33525 -j REJECT
# Protecoes contra ataques
iptables -A INPUT -m state --state INVALID -j REJECT
#BARRANDO ACESSO AO NTOP PARA O MUNDO E LIBERANDO PARA REDE INTERNA
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3000 -j DROP
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 3000 -j ACCEPT
iptables -t filter -A INPUT -i eth1 -p tcp --dport 3000 -j ACCEPT
#iMesh:
iptables -A FORWARD -d 216.35.208.0/24 -j REJECT
#Bloqueando os -:P2P:- (se voc? deseja utilizar um desses softwares, apenas retire o coment?rio # e substitua a condi??o de: REJECT, para ACCEPT)
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 6881:6889 -j DNAT --to-dest 192.168.1.250
iptables -A FORWARD -p tcp -i eth0 --dport 6881:6889 -d 192.168.1.250 -j REJECT
#BearShare:
iptables -A FORWARD -p tcp --dport 6346 -j REJECT
#WinMX:
iptables -A FORWARD -d 209.61.186.0/24 -j REJECT
iptables -A FORWARD -d 64.49.201.0/24 -j REJECT
#Napigator:
iptables -A FORWARD -d 209.25.178.0/24 -j REJECT
#Morpheus:
iptables -A FORWARD -d 206.142.53.0/24 -j REJECT
iptables -A FORWARD -p tcp --dport 1214 -j REJECT
#KaZaA:
iptables -A FORWARD -d 213.248.112.0/24 -j REJECT
iptables -A FORWARD -p tcp --dport 1214 -j REJECT
#Limewire:
iptables -A FORWARD -p tcp --dport 6346 -j REJECT
#Audiogalaxy:
iptables -A FORWARD -d 64.245.58.0/23 -j REJECT
iptables -A FORWARD -m string --string "find_node" --algo bm -j DROP
Se houver algo errado fique a vontade.
Obrigado