xlinux
(usa Ubuntu)
Enviado em 04/10/2013 - 09:58h
vou postar aqui os dois completos...
Squid
##Squid.conf
http_port 3128 transparent
visible_hostname servidor
error_directory /usr/share/squid3/errors/Portuguese
#Diretório 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
#Memória do cache
cache_mem 512 MB
#Usar o máximo de memória possível
memory_pools on
memory_pools_limit 2048 MB
#Tamanho máximo 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
http_access deny !Safe_ports
# ACL PARA CONEXAO METODO SSL
acl CONNECT method CONNECT
http_access deny CONNECT !SSL_ports
# ACLs PARA LIBERACAO TOTAL POR MAC
#acl mac_liberados arp "/etc/squid3/mac_liberados"
#http_access allow mac_liberados
# ACLs PARA SITES LIBERADOS
#acl sites_liberados url_regex -i "/etc/squid3/sites_liberados"
#http_access allow sites_liberados
# ACLs PARA SITES BLOQUEADOS
acl sites_bloqueados url_regex -i "/etc/squid3/sites_bloqueados"
http_access deny sites_bloqueados
acl localnet src 192.168.1.0/24
# Politicas para rede local
http_access allow localnet
http_access deny all
Firewall
#!/bin/sh
# Start/stop/restart the iptables.
# Start firewall:
firewall_start() {
echo "Starting iptables"
## CARREGAR MODULOS DE FIREWALL ##
modprobe ip_nat_ftp
modprobe ip_tables
##COMPARTILHANDO A INTERNET
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
## 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="eth0"
IFLAN="eth1"
#IFVPN="tun0"
# Manter conexoes jah estabelecidas para nao parar
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
## LIBERA LOOPBACK ##
$IPTABLES -t filter -A INPUT -j ACCEPT -i lo
## PROTEÇÕES
#PROTEGE CONTRA OS "PING OF DEATH"
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -m limit --limit 20/m -j ACCEPT
$IPTABLES -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 20/m -j ACCEPT
# 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
## 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 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 AS REQUISIÇÕES PARA PROXY
$IPTABLES -t nat -A PREROUTING -i 192.168.1.0/255.255.255.0 -p tcp --dport 80 -j REDIRECT --to-port 3128
$IPTABLES -t nat -A POSTROUTING -o eth0 -j MASQUERADE
## LIBERA ACESSO AO DNS SERVER PARA LAN##
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 8.8.8.8 -p udp --dport 53
$IPTABLES -t filter -A INPUT -j ACCEPT -i $IFLAN -s 192.168.1.0/24 -d 8.8.4.4 -p udp --dport 53
# LIBERA O ACESSO A CLIENTES DE EMAIL,POP E SMTP
#$IPTABLES -A FORWARD -p tcp -m multiport --dports 25,110,143,993,995 -j ACCEPT
# LIBERA O ACESSO AO http https FTP
#$IPTABLES -A FORWARD -p tcp -m multiport --dports 21,80,443,80 -j ACCEPT
}
# 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
Aceito sugestões de melhora nas configurações;....
Obrigado