simberg
(usa Debian)
Enviado em 04/11/2015 - 14:09h
# Proxy transparente
http_port 3127 intercept
http_port 8080
dns_v4_first on
visible_hostname firewall21.fd.local
hierarchy_stoplist cgi-bin ?
# Memória usada pelo cache
cache_mem 500 MB
# Máximo tamanho de objetos na RAM
maximum_object_size_in_memory 1024 KB
# Máximo de objetos no cache do disco. Os downloads
maximum_object_size 16 MB
# Tamanho mínimo dos objetos no cache
minimum_object_size 0 KB
# Porcentagem para descarte do cache
cache_swap_low 90
cache_swap_high 95
#Acesso ao squid balanceador
#cache_peer 10.10.10.22 sibling 3128 3130 proxy_only
#cache_peer_access 10.10.10.22 allow all
acl balanceador src 10.10.10.17
http_access allow balanceador
acl firewall22 src 10.10.10.22
http_access allow firewall22
acl firewall21 src 10.10.10.21
http_access allow firewall21
follow_x_forwarded_for allow all
#--------------
#acl QUERY urlpath_regex cgi-bin \?
#no_cache deny QUERY
# Tamanho total do cache em disco, endereco do cache, qtde de pastas e subpastas
cache_dir diskd /var/spool/squid3/01 1024 64 256 Q1=64 Q2=72
cache_dir diskd /var/spool/squid3/02 1024 64 256 Q1=64 Q2=72
cache_dir diskd /var/spool/squid3/03 1024 64 256 Q1=64 Q2=72
cache_dir diskd /var/spool/squid3/04 1024 64 256 Q1=64 Q2=72
cache_replacement_policy lru
memory_replacement_policy lru
# Endereço dos logs
cache_access_log /var/log/squid3/access.log
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
# acl dos IPS liberados
acl ip_liberados src "/etc/squid3/ip_liberados"
# acl de malware
acl malware_block_list url_regex -i "/etc/squid3/malware_block_list"
# acl de bloqueio de extensoes (CMD, BAT, PIF, SCR)
acl download urlpath_regex \.(cmd|bat|pif|scr)([-?+=&/_]$)
#acl direto url_regex -i "/etc/squid3/direto"
#always_direct allow direto
# acl bloqueio MSN e Orkut
acl block_msn_orkut url_regex -i "/etc/squid3/block_msn_orkut"
# acl da Pagina inicial do IE
acl msn_liberado url_regex -i "/etc/squid3/msn_liberado"
#acl manager proto cache_object
#acl localhost src 127.0.0.1/32
#acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563 10082
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 85 #
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65353 # unrestered 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 10082 # Net Life
acl Safe_ports port 809 # SPtrans
acl Safe_ports port 6991 #Alef
acl Safe_ports port 3128 3127 #Squid3
acl Safe_ports port 3130 #Requisicao Load-balance
acl CONNECT method CONNECT
acl rede_interna src 10.10.10.0
http_access allow rede_interna
http_access allow manager localhost
#http_access deny manager
#http_access deny !Safe_ports
#http_access deny CONNECT !SSL_ports
http_access allow diretor
#http_access deny download
#http_access deny malware_block_list
#http_access deny block_msn_orkut !msn_liberado
http_access allow ip_reserva_salas
#http_access deny url_reserva_salas
http_access allow ip_liberados
http_access allow TERMINAL_LABEO libera_labeo
#http_access deny all
http_reply_access allow all
icp_access allow all
#Limitar download a 1000MB
reply_body_max_size 1000 MB
error_directory /usr/share/squid3/errors/pt-br
cache_store_log none
----------------------------------------
IPtables
-------------------------------
#!/bin/bash
### BEGIN INIT INFO
# Provides: regras.sh
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start regras.sh at boot time
# Description: Enable service provided by regras.sh
### END INIT INFO
# chkconfig: 345 99 10
# description: regras
start(){
modprobe ip_nat_ftp
modprobe ip_tables
modprobe iptable_nat
modprobe ip_conntrack_ftp
modprobe ip_conntrack
#Removendo regras
iptables -F
iptables -X
iptables -F INPUT
iptables -F OUTPUT
iptables -F POSTROUTING -t nat
iptables -F PREROUTING -t nat
iptables -F POSTROUTING -t mangle
iptables -F PREROUTING -t mangle
WAN="eth0"
#Liberando acesso interno da rede
iptables -A INPUT -p tcp --syn -s 10.10.0.0/16 -j ACCEPT
iptables -A OUTPUT -p tcp --syn -s 10.10.0.0/16 -j ACCEPT
iptables -A FORWARD -p tcp --syn -s 10.10.0.0/16 -j ACCEPT
#Redirecionando navegação para o Proxy
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3127
#Mascaramento
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
#Liberando portas
iptables -A INPUT -p tcp --destination-port 8080 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 80 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 2022 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 137 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 138 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 139 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 7070 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 1755 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 554 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 443 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 1935 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3128 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3127 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3130 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 1080 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 11111 -j ACCEPT
#Permitindo que os pacotes passem pelo Firewall
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -s 10.10.0.0/16 -o eth0 -j ACCEPT
#Bloqueando
#Protecao contra port scanners ocultos
#iptables -A INPUT -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
#Bloqueando Tracertroute
#iptables -A INPUT -p udp -s 0/0 -i eth0 --dport 33435:33525 -j DROP
#Bloqueando Bittorent
#iptables -A INPUT -p tcp -s 0/0 -i eth0 --dport 6881:6889 -j DROP
#Proteção contra ataques
#iptables -A INPUT -m state --state INVALID -j DROP
#Bloqueia qualquer outro tipo de tráfego desconhecido
}
case "$1" in
"start") start ;;
*)
echo
echo "use start"
;;
esac
----------------------------------------------------------------------------------------------
Para a outra máquina virtual 10.10.10.22 - firewall 22, considere a mesma configuração.