Buckminster
(usa Debian)
Enviado em 30/04/2013 - 18:56h
Testa esse squid.conf:
http_port 3128 intercept
cache_mem 2000 MB
cache_dir ufs /var/spool/squid3 5000 16 256
visible_hostname SK5
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
#
acl SSL_ports port 443 # 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 z39.50
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 CONNECT method CONNECT
#
http_access allow localhost manager
http_access deny manager
#
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny to_localhost
#
acl permitido url_regex -i "/etc/squid3/permitido.txt"
acl restrito url_regex -i "/etc/squid3/restrito.txt"
acl coord src 192.168.1.5 192.168.1.8
http_access allow coord
http_access allow permitido
#
acl localnet src 192.168.1.0/24
http_access deny restrito
http_access allow localhost
http_access allow localnet
http_access deny all
#
cache_log /etc/squid3/var/logs/cache.log
coredump_dir /etc/squid3/var/cache/squid
E esse IPtables:
#!/bin/bash
##Apagando e restaurando as chains e tabelas
##############################
iptables -Z # Zera as regras das chains
iptables -F # Remove as regras das chains
iptables -X # Apaga as chains
iptables -t nat -Z
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -Z
iptables -t mangle -F
iptables -t mangle -X
#
echo "0" > /proc/sys/net/ipv4/ip_forward
#
##Protecao contra ping, SYN Cookie, IP Spoofing e protecoes do kernel
##############################################
echo 1 > /proc/sys/net/ipv4/tcp_syncookies #Syn Flood
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts # Port scanners
#echo 0 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses #Sem resposta remota
#for i in /proc/sys/net/ipv4/conf/*; do
#echo 0 > $i/accept_redirects #Sem redirecionar rotas
#echo 0 > $i/accept_source_route #Sem traceroute
#echo 1 > $i/log_martians #Loga pacotes suspeitos no kernel
#echo 1 > $i/rp_filter #Ip Spoofing
#echo 1 > $i/secure_redirects; done #Redirecionamento seguro de pacotes
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all #Sem ping e tracert
#
# Levantando os modulos
#################
modprobe ip_tables
modprobe iptable_nat
#
# Definindo as politicas padroes
####################
iptables -P INPUT DROP # iptables a política padrão da chain INPUT é proibir tudo
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
#
##Liberando a Loopback
###############
iptables -A FORWARD -o lo -j ACCEPT
#
##Regras de segurança na internet e acessos
#############################
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW ! -i eth0 -j DROP # Interface de entrada da internet
iptables -A FORWARD -m state --state NEW ! -i eth0 -j DROP
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A FORWARD -m state --state INVALID -j DROP
#
##Liberando portas somente para a rede interna
#############################
iptables -A INPUT -p tcp --dport 3128 -i eth1 -j ACCEPT #Proxy
iptables -A INPUT -p tcp --dport 80 -i eth1 -j ACCEPT #HTTP
iptables -A INPUT -p tcp --dport 21 -i eth1 -j ACCEPT #FTP
iptables -A INPUT -p tcp --dport 53 -i eth1 -j ACCEPT #DNS
iptables -A INPUT -p udp --dport 53 -i eth1 -j ACCEPT #DNS
iptables -A INPUT -p tcp --dport 25 -i eth1 -j ACCEPT #SMTP
iptables -A INPUT -p tcp --dport 110 -i eth1 -j ACCEPT #SSL
iptables -A INPUT -p udp --dport 110 -i eth1 -j ACCEPT #SSL
#iptables -A INPUT -p tcp --dport 8080 -i eth1 -j ACCEPT #HTTP - Apache
#iptables -A INPUT -p udp --dport 8080 -i eth1 -j ACCEPT #HTTP - Apache
#
echo "1" > /proc/sys/net/ipv4/ip_forward
#
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
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
São arquivos básicos.
Veja bem, dá uma conferida nas eth0 e eth1. A eth0 nesses arquivos está como interface de entrada da internet e a eth1 como interface de saída para a rede interna.
Testa e prende o grito se der alguma coisa errada.
Caso contrário vamos implementando mais algumas regras. Mas daí é com você. A partir de agora só vou prestar um auxílio. Acredito que você já tem condições de resolver problemas com tudo que foi te passado aqui.
Qualquer dúvida, prende o grito.