rolihlahla
(usa Debian)
Enviado em 16/01/2014 - 18:44h
Http não navega, somente https, quando comento a linha de redirecionamento para squid (3128) funciona perfeitamente. Script iptables:
#!/bin/bash
echo #######
echo Regras Firewall Inicializadas!
echo #######
sleep 0
IF_WAN=eth0 # Interface de saida para internet
LAN=192.168.10.0/24 # Endereco rede local
# Limpa regras firewall
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -t nat -F
# Ativa roteamento
echo 1 > /proc/sys/net/ipv4/ip_forward
# Navegacao rapida
iptables -A INPUT -i lo -j ACCEPT
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 RELATED,ESTABLISHED -j ACCEPT
# Mantem o estado das conexoes da interface de loopback
iptables -I INPUT -s 127.0.0.1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I OUTPUT -s 127.0.0.1 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Libera acesso do proprio servidor para servicos locais
iptables -I INPUT -p tcp -s 127.0.0.1 -d 127.0.0.1 --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -s 127.0.0.1 -d 127.0.0.1 --dport 25 -j ACCEPT
iptables -I INPUT -p tcp -s 127.0.0.1 -d 127.0.0.1 --dport 53 -j ACCEPT
iptables -I INPUT -p tcp -s 127.0.0.1 -d 127.0.0.1 --dport 110 -j ACCEPT
iptables -A INPUT -p tcp -s 127.0.0.1 -d 127.0.0.1 --dport 443 -j ACCEPT
iptables -I INPUT -p tcp -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -I INPUT -p udp -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
# SSH
iptables -A FORWARD -i eth1 -p tcp -s 192.168.10.0/24 -d 0/0 --dport 22 -j ACCEPT
# ICMP
iptables -A FORWARD -i eth1 -p icmp -s 192.168.10.0/24 -d 0/0 -j ACCEPT
# DNS
iptables -A FORWARD -i eth1 -p udp -s 192.168.10.0/24 -d 0/0 --dport 53 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# Ativa modo masquerade
iptables -t nat -A POSTROUTING -o $IF_WAN -j MASQUERADE # mascaramento de rede
# Acesso total por ip - Nao passa pelo proxy
iptables -t nat -A PREROUTING -i eth1 -p tcp -s 192.168.10.201 -j RETURN
iptables -t nat -A PREROUTING -i eth1 -p tcp -s 192.168.10.251 -j RETURN
Se comento essa linha funciona perfeitamente os dois protocolos (http e https)
# Forca navegacao 3128
--> iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -s $LAN -j REDIRECT --to 3128 # forca navegacao na 3128
# Libera porta banco de dados firebird
iptables -A INPUT -p tcp -s $LAN --dport 3050 -j ACCEPT
# Libera portas pabx
iptables -A INPUT -p udp -s $LAN --dport 21 -j ACCEPT
iptables -A INPUT -p udp -s $LAN --dport 22 -j ACCEPT
iptables -A INPUT -p udp -s $LAN --dport 23 -j ACCEPT
iptables -A INPUT -p udp -s $LAN --dport 50000:50020 -j ACCEPT
# Libera portas
PORTAS_TCP="53,443,9100"
PORTAS_UDP="53,443,515"
iptables -A FORWARD -p tcp -m multiport --dports $PORTAS_TCP -j ACCEPT
iptables -A FORWARD -p udp -m multiport --dports $PORTAS_UDP -j ACCEPT
# Libera portas a forca
iptables -A INPUT -p TCP --dport 9100 -j ACCEPT
iptables -A OUTPUT -p TCP --dport 9100 -j ACCEPT
iptables -A FORWARD -p TCP --dport 9100 -j ACCEPT
iptables -A INPUT -p UDP --dport 9100 -j ACCEPT
iptables -A OUTPUT -p UDP --dport 9100 -j ACCEPT
iptables -A FORWARD -p UDP --dport 9100 -j ACCEPT
iptables -A INPUT -p TCP --dport 515 -j ACCEPT
iptables -A OUTPUT -p TCP --dport 515 -j ACCEPT
iptables -A FORWARD -p TCP --dport 515 -j ACCEPT
iptables -A INPUT -p UDP --dport 515 -j ACCEPT
iptables -A OUTPUT -p UDP --dport 515 -j ACCEPT
iptables -A FORWARD -p UDP --dport 515 -j ACCEPT
# Libera samba/compartilhamento de arquivos
iptables -A INPUT -p udp -s $LAN --dport 137 -j ACCEPT #netbios-ns
iptables -A INPUT -p udp -s $LAN --dport 138 -j ACCEPT #netbios-dgm
iptables -A INPUT -p tcp -s $LAN --dport 139 -j ACCEPT #netbios-ssn
iptables -A INPUT -p tcp -s $LAN --dport 445 -j ACCEPT #microsoft-ds
# Fim
--------------------------------------------
Script squid:
http_port 3128 transparent
visible_hostname Firewall
# 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 23 80 138 139 443 563 70 210 280 488 59 777 901 9100 50000-50020
acl purge method PURGE
acl CONNECT method CONNECT
acl webserver src 192.168.10.1/255.255.255.255
http_access allow manager webserver
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
###########################SquidGuard###########################
redirect_program /usr/bin/squidGuard
redirect_children 8
redirector_bypass on
# Validação da rede local
acl redelocal src 192.168.10.0/24
# Bloqueio de sites por dominio
acl sites url_regex -i "/etc/squid/bloqueados/sites"
http_access deny sites
# Bloqueio
[*****]
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
http_access allow localhost
http_access allow redelocal
http_access deny all