xlinux
(usa Ubuntu)
Enviado em 02/09/2013 - 15:28h
segue meu squid e firewall
http_port 192.168.1.2:3128 transparent
visible_hostname atenas
# Proxy transparent com autenticacao não funciona
error_directory /usr/share/squid/errors/Portuguese/
cache_mem 64 MB
maximum_object_size_in_memory 64 KB
maximum_object_size 512 MB
minimum_object_size 0 KB
cache_swap_low 50
cache_swap_high 70
cache_dir ufs /var/spool/squid 2048 16 256
cache_access_log /var/log/squid/access.log
#cache_store_log /var/log/squid/store.log
#cache_swap_log /var/log/squid/cache_swap.log
refresh_pattern ^ftp: 15 20% 2280
refresh_pattern ^gopher: 15 0% 2280
refresh_pattern . 15 20% 2280
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 22 995 993 465
acl Safe_ports port 21 80 138 139 443 563 70 210 280 488 59 777 901 1025-65535
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 deny CONNECT !SSL_ports
# Validação da rede local
acl redelocal src 192.168.1.0/24
# Bloqueio de sites por dominio
#acl sites url_regex -i "/etc/squid/bloqueados/sites"
#http_access deny sites
#acl
[*****] url_regex -i "/etc/squid/bloqueados/
[*****]"
#http_access deny
[*****]
# Bloqueio de arquivos por extensão
#acl extensao urlpath_regex -i "/etc/squid/bloqueados/extensao"
#http_access deny extensao
# Controle de banda de acesso a internet
# 15728640 = 15Mb de banda total contratada junto a operadora = 1,5MB/s
# 1048576 = 1Mb de banda controlada = 128Kb/s de velocidade máxima de download por usuario
# 2097152 = 2mb de banda controlada = 256Kb/s de velocidade máxima de donwload por
#delay_pools 1
#delay_class 1 2
#delay_parameters 1 15728640/15728640 1048576/1048576
#delay_parameters 1 -1/-1 15728640/15728640 1048576/1048576 # 0 -1/-1 é ilimitado o uso
#delay_parameters 1 32000/32000 1048576/1048576
#delay_access 1 allow redelocal
http_access allow localhost
http_access allow redelocal
http_access deny all
FIREWALL
#!/bin/sh
# Start/stop/restart the iptables.
# Start firewall:
firewall_start() {
echo "Starting iptables"
## CARREGAR MODULOS DE FIREWALL ##
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_conntrack_ftp
## LIMPANDO TABELAS ##
/sbin/iptables -t filter -F INPUT
/sbin/iptables -t filter -F FORWARD
/sbin/iptables -t filter -F OUTPUT
/sbin/iptables -t nat -F PREROUTING
/sbin/iptables -t nat -F POSTROUTING
/sbin/iptables -t nat -F OUTPUT
/sbin/iptables -t mangle -F PREROUTING
/sbin/iptables -t mangle -F INPUT
/sbin/iptables -t mangle -F FORWARD
/sbin/iptables -t mangle -F OUTPUT
/sbin/iptables -t mangle -F POSTROUTING
## DEFININDO POLITICA PADRÃO ##
/sbin/iptables -t filter -P INPUT DROP
/sbin/iptables -t filter -P FORWARD DROP
/sbin/iptables -t filter -P OUTPUT ACCEPT
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
## REGRAS ##
IPTABLES="/sbin/iptables"
IFNET="eth1"
IFLAN="eth0"
## LIBERA LOOPBACK ##
$IPTABLES -t filter -A INPUT -j ACCEPT -i lo
## LIBERA RETORNO DE PACOTES ##
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFNET -m state --state ESTABLISHED,RELATED
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFLAN -m state --state ESTABLISHED,RELATED
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFCELG -m state --state ESTABLISHED,RELATED
$IPTABLES -t filter -A FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED
## LIBERA PARA LAN O ENVIO DE PING PARA WAN ##
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -o $IFNET -p icmp
##REDIRECIONA O TRAFEGO PARA A PORTA 3128
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
## LIBERA ACESSO AO DNS SERVER PARA LAN##
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 192.168.1.2 -p udp --dport 53
## LIBERA ACESSO AO NTOP PARA LAN POR 192.168.1.2 ##
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFLAN -s 192.168.1.2 -d 192.168.1.1 -p tcp --dport 3000
## LIBERA ACESSO AO PROXY SERVER PARA LAN ##
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 192.168.1.2 -p tcp --dport 3128
## NAT - MASCARA PACOTES QUE SAEM PARA WAN ##
$IPTABLES -t nat -A POSTROUTING -j MASQUERADE -o $IFNET -s 192.168.1.0/24 -d 0/0
## LIBERAR PAULINHO ##
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -o $IFNET -s 192.168.1.0/24 -d 0/0 -p tcp --dport 1433
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -o $IFNET -s 192.168.1.0/24 -d 0/0 -p tcp --dport 5432
## LIBERAR FTP CLIENT ##
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 0/0 -p tcp --dport 21
## LIBERAR SMTP CLIENT ##
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 200.175.152.201 -p tcp --dport 25
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 200.175.152.201 -p tcp --dport 587
## LIBERAR POP3 CLIENT ##
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 200.175.152.201 -p tcp --dport 110
## LIBERAR ENTREGA DE IRPF ##
#$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 161.148.185.130 -p tcp --dport 3456
#$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 161.148.185.120 -p tcp --dport 3456
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 0/0 -p tcp --dport 3456
## LIBERAR CAT ##
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 200.152.32.148 -p tcp --dport 5017
## LIBERAR CVS CLIENT ##
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 0/0 -p tcp --dport 2401
#### VNC ####
$IPTABLES -t filter -A FORWARD -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 0/0 -p tcp --dport 5900
}
# Stop firewall:
firewall_stop() {
/sbin/iptables -t filter -F INPUT
/sbin/iptables -t filter -F FORWARD
/sbin/iptables -t filter -F OUTPUT
/sbin/iptables -t nat -F PREROUTING
/sbin/iptables -t nat -F POSTROUTING
/sbin/iptables -t nat -F OUTPUT
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
}
# Restart firewall:
firewall_restart() {
firewall_stop
sleep 1
firewall_start
}
case "$1" in
'start')
firewall_start
;;
'stop')
firewall_stop
;;
'restart')
firewall_restart
;;
*)
echo "usage $0 start|stop|restart"
esac