Squid3 Proxy Tranparent [RESOLVIDO]

25. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 11/12/2012 - 17:38h

alguem pode ajudar.........up


  


26. Re: Squid3 Proxy Tranparent [RESOLVIDO]

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 11/12/2012 - 18:01h

Cara não vi nada de errado nas suas configurações.

Esta rodando o comando:

squid -k reconfigure após as mudanças?


27. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 11/12/2012 - 18:40h

andrecanhadas escreveu:

Cara não vi nada de errado nas suas configurações.

Esta rodando o comando:

squid -k reconfigure após as mudanças?


sim.... to achando que é o firewall


28. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 12/12/2012 - 09:21h

aqui meu firewall se alguem poder me ajudar agradeço....


#!/bin/bash

################################################################################
#################### Inicio Firewall ###########################################
################################################################################
# Variaveis:
rede_mask=192.168.1.0/24
iface_int=eth0
iface_ext=eth1

echo “Carregando Modulos”
/sbin/modprobe ip_nat
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_queue
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe iptable_mangle
/sbin/modprobe ipt_state
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_multiport
/sbin/modprobe ipt_mac
/sbin/modprobe ipt_string

echo “Limpando as Regras existentes”
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -t mangle -F
/sbin/iptables -t filter -F
/sbin/iptables -X
/sbin/iptables -Z

## Definindo politica padr..o (Nega entrada e permite saida)
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT



################################################################################
######################## Protege contra ataques diversos #######################
################################################################################
echo “Ativando Proteção contra ataques”
###### Protege contra synflood
/sbin/iptables -A FORWARD -p tcp –syn -m limit –limit 1/s -j ACCEPT
echo 1 > /proc/sys/net/ipv4/tcp_syncookies

###### Protecao contra ICMP Broadcasting
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
###### Prote.. Contra IP Spoofing
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter

###### Protecao diversas contra portscanners, ping of death, ataques DoS, pacotes danificados e etc.
#/sbin/iptables -A FORWARD -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
#/sbin/iptables -A INPUT -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
#/sbin/iptables -A INPUT -i $iface_ext -p icmp –icmp-type echo-reply -m limit –limit 1/s -j DROP
/sbin/iptables -A FORWARD -p tcp -m limit –limit 1/s -j ACCEPT
/sbin/iptables -A FORWARD -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -p tcp –tcp-flags SYN,ACK,FIN,RST RST -m limit –limit 1/s -j ACCEPT
/sbin/iptables -A FORWARD –protocol tcp –tcp-flags ALL SYN,ACK -j DROP
/sbin/iptables -A INPUT -m state –state INVALID -j DROP
/sbin/iptables -A FORWARD -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -N VALID_CHECK
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL FIN,URG,PSH -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL ALL -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL FIN -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags SYN,RST SYN,RST -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags SYN,FIN SYN,FIN -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL NONE -j DROP

################################################################################

######################### Fim da regras de contra ataques ######################
################################################################################

## Impede navega….o sem proxy definido no navegador ##########
/sbin/iptables -t nat -A PREROUTING -i $iface_int -p tcp –dport 80 -j REDIRECT –to-port 3128

## Impede o uso de outro proxy externo que use a porta 8080
/sbin/iptables -t nat -A PREROUTING -i $iface_int -p tcp –dport 8080 -j REDIRECT –to-port 3128

## Estabelece rela….o de confian..a entre maquinas da rede local $iface_int(rede local)
/sbin/iptables -A INPUT -i $iface_int -s $rede_mask -j ACCEPT
/sbin/iptables -A INPUT -i $iface_int -m state –state NEW -j ACCEPT
/sbin/iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

## liberando o INPUT externo para o firewall ##

## Portas ##

# SSH – HTTP – SSL – RDP
/sbin/iptables -A INPUT -i $iface_ext -p tcp -m multiport –dport 22,3389 -j ACCEPT

# VPN Windows Server
#/sbin/iptables -A FORWARD -p tcp -i $iface_ext –dport 1723 -j ACCEPT
#/sbin/iptables -A FORWARD -p 47 -i $iface_ext -j ACCEPT



################################################################################

################# Redirecionamento para maquinas de rede interna ###############
################################################################################

## VPN

#/sbin/iptables -A PREROUTING -t nat -p tcp -i $iface_ext –dport 1723 -j DNAT –to 192.168.0.x:1723
#/sbin/iptables -A PREROUTING -t nat -p 47 -i $iface_ext -j DNAT –to 192.168.0.x
## SSH Outra maquina

## RDP
#/sbin/iptables -t nat -A PREROUTING -i $iface_ext -p tcp -m tcp –dport 3389 -j DNAT –to-destination 192.168.0.x:3389
############## Testes ##########################################################
######################################################################################
###################### Bloqueio de HTTPS #############################################
######################################################################################

# Youtube / Facebook
#/sbin/iptables -I FORWARD -m string –algo bm –string “facebook.com” -j DROP
#/sbin/iptables -I FORWARD -m string –algo bm –string “youtube.com” -j DROP
#/sbin/iptables -I OUTPUT -m string –algo bm –string “facebook.com” -j DROP
#/sbin/iptables -I OUTPUT -m string –algo bm –string “youtube.com” -j DROP

################################################################################
################################# Bloqueio de entrada ##########################
################################################################################
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -i $iface_int -j ACCEPT
/sbin/iptables -A OUTPUT -p icmp –icmp-type echo-request -j ACCEPT
#/sbin/iptables -A INPUT -p icmp –icmp-type echo-reply -j ACCEPT
/sbin/iptables -A INPUT -i $iface_ext -j REJECT
## Liberar ping ## 0=on 1=off
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all

################################################################################
############################ Compartilhamento Internet #########################
################################################################################

/sbin/iptables -t nat -A POSTROUTING -o $iface_ext -j MASQUERADE
/sbin/iptables -t nat -A POSTROUTING -o $iface_int -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward

echo “Firewall Ativado”
################################################################################
######################################## Fim ###################################
#########################################################


29. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 12/12/2012 - 18:34h

up


30. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 12/12/2012 - 19:00h

o problema ta no firewall no squid coloquei para bloquear tudo e nada.... se alguem poder me ajudar


31. Re: Squid3 Proxy Tranparent [RESOLVIDO]

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 12/12/2012 - 20:55h

lirocat escreveu:

o problema ta no firewall no squid coloquei para bloquear tudo e nada.... se alguem poder me ajudar


Se colocar o proxy manualmente funciona?


32. Re: Squid3 Proxy Tranparent [RESOLVIDO]

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 12/12/2012 - 21:11h

No seu squid.conf troque # http_port 3128 transparent por :

http_port 3128 intercept


Remova as acl safe port das portas 25,110,587 o squid não controla este trafego.

Mude # cache_dir ufs /var/spool/squid3 45000 16 256 para:


cache_dir aufs /var/spool/squid3 45000 16 256



o AUFS administra melhor o processamento e memoria usada.

No firewall troque o rede_mask=192.168.1.0/24

para:

192.168.0.0/24



Remova a linha:

/sbin/iptables -t nat -A POSTROUTING -o $iface_int -j MASQUERADE


Poste a saida de # ifconfig -a para ver se as eth0´s estão corretas como pede o firewall


33. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 13/12/2012 - 09:46h

andrecanhadas escreveu:

No seu squid.conf troque # http_port 3128 transparent por :

http_port 3128 intercept


Remova as acl safe port das portas 25,110,587 o squid não controla este trafego.

Mude # cache_dir ufs /var/spool/squid3 45000 16 256 para:


cache_dir aufs /var/spool/squid3 45000 16 256



o AUFS administra melhor o processamento e memoria usada.

No firewall troque o rede_mask=192.168.1.0/24

para:

192.168.0.0/24



Remova a linha:

/sbin/iptables -t nat -A POSTROUTING -o $iface_int -j MASQUERADE


Poste a saida de # ifconfig -a para ver se as eth0´s estão corretas como pede o firewall


ainda nao bloquea os sites

eth0 Link encap:Ethernet Endereço de HW f8:d1:11:04:0b:fe
inet end.: 192.168.10.87 Bcast:192.168.10.255 Masc:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Métrica:1
pacotes RX:515903 erros:0 descartados:0 excesso:0 quadro:0
Pacotes TX:381406 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:1000
RX bytes:555454320 (555.4 MB) TX bytes:53717116 (53.7 MB)
IRQ:16 Endereço de E/S:0xa000

eth1 Link encap:Ethernet Endereço de HW 14:da:e9:ef:89:02
inet end.: 192.168.0.96 Bcast:192.168.0.255 Masc:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Métrica:1
pacotes RX:454430 erros:0 descartados:0 excesso:0 quadro:0
Pacotes TX:490340 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:1000
RX bytes:59097562 (59.0 MB) TX bytes:533883596 (533.8 MB)
IRQ:49 Endereço de E/S:0xc000

lo Link encap:Loopback Local
inet end.: 127.0.0.1 Masc:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Métrica:1
pacotes RX:498 erros:0 descartados:0 excesso:0 quadro:0
Pacotes TX:498 erros:0 descartados:0 excesso:0 portadora:0
colisões:0 txqueuelen:0
RX bytes:187183 (187.1 KB) TX bytes:187183 (187.1 KB)




34. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 13/12/2012 - 09:48h

andrecanhadas escreveu:

lirocat escreveu:

o problema ta no firewall no squid coloquei para bloquear tudo e nada.... se alguem poder me ajudar


Se colocar o proxy manualmente funciona?


manualmente tbm nao bloquea


35. Re: Squid3 Proxy Tranparent [RESOLVIDO]

Alex
lirocat

(usa Outra)

Enviado em 13/12/2012 - 10:07h

lirocat escreveu:

andrecanhadas escreveu:

lirocat escreveu:

o problema ta no firewall no squid coloquei para bloquear tudo e nada.... se alguem poder me ajudar


Se colocar o proxy manualmente funciona?


manualmente tbm nao bloquea


corrigi algumas coisas

agora se eu colocar manualmente e tiver para bloquear o youtube ele bloquear tanto http como https do youtube beleza

agora se usar transparente ele bloquear somente http o https nao bloquear

acho que estamos próximo da solução andrecanhadas


36. Re: Squid3 Proxy Tranparent [RESOLVIDO]

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 13/12/2012 - 10:45h

sim faltou alterar as placas no inicio do firewall estão invertidas:

#!/bin/bash

################################################################################
#################### Inicio Firewall ###########################################
################################################################################
# Variaveis:
rede_mask=192.168.0.0/24
iface_int=eth1
iface_ext=eth0

echo “Carregando Modulos”
/sbin/modprobe ip_nat
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_queue
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe iptable_mangle
/sbin/modprobe ipt_state
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_multiport
/sbin/modprobe ipt_mac
/sbin/modprobe ipt_string

echo “Limpando as Regras existentes”
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -t mangle -F
/sbin/iptables -t filter -F
/sbin/iptables -X
/sbin/iptables -Z

## Definindo politica padr..o (Nega entrada e permite saida)
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT



################################################################################
######################## Protege contra ataques diversos #######################
################################################################################
echo “Ativando Proteção contra ataques”
###### Protege contra synflood
/sbin/iptables -A FORWARD -p tcp –syn -m limit –limit 1/s -j ACCEPT
echo 1 > /proc/sys/net/ipv4/tcp_syncookies

###### Protecao contra ICMP Broadcasting
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
###### Prote.. Contra IP Spoofing
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter

###### Protecao diversas contra portscanners, ping of death, ataques DoS, pacotes danificados e etc.
#/sbin/iptables -A FORWARD -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
#/sbin/iptables -A INPUT -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
#/sbin/iptables -A INPUT -i $iface_ext -p icmp –icmp-type echo-reply -m limit –limit 1/s -j DROP
/sbin/iptables -A FORWARD -p tcp -m limit –limit 1/s -j ACCEPT
/sbin/iptables -A FORWARD -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -p tcp –tcp-flags SYN,ACK,FIN,RST RST -m limit –limit 1/s -j ACCEPT
/sbin/iptables -A FORWARD –protocol tcp –tcp-flags ALL SYN,ACK -j DROP
/sbin/iptables -A INPUT -m state –state INVALID -j DROP
/sbin/iptables -A FORWARD -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -N VALID_CHECK
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL FIN,URG,PSH -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL ALL -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL FIN -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags SYN,RST SYN,RST -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags SYN,FIN SYN,FIN -j DROP
/sbin/iptables -A VALID_CHECK -p tcp –tcp-flags ALL NONE -j DROP

################################################################################

######################### Fim da regras de contra ataques ######################
################################################################################

## Impede navega….o sem proxy definido no navegador ##########
/sbin/iptables -t nat -A PREROUTING -i $iface_int -p tcp –dport 80 -j REDIRECT –to-port 3128

## Impede o uso de outro proxy externo que use a porta 8080
/sbin/iptables -t nat -A PREROUTING -i $iface_int -p tcp –dport 8080 -j REDIRECT –to-port 3128

## Estabelece rela….o de confian..a entre maquinas da rede local $iface_int(rede local)
/sbin/iptables -A INPUT -i $iface_int -s $rede_mask -j ACCEPT
/sbin/iptables -A INPUT -i $iface_int -m state –state NEW -j ACCEPT
/sbin/iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

## liberando o INPUT externo para o firewall ##

## Portas ##

# SSH – HTTP – SSL – RDP
/sbin/iptables -A INPUT -i $iface_ext -p tcp -m multiport –dport 22,3389 -j ACCEPT

# VPN Windows Server
#/sbin/iptables -A FORWARD -p tcp -i $iface_ext –dport 1723 -j ACCEPT
#/sbin/iptables -A FORWARD -p 47 -i $iface_ext -j ACCEPT



################################################################################

################# Redirecionamento para maquinas de rede interna ###############
################################################################################

## VPN

#/sbin/iptables -A PREROUTING -t nat -p tcp -i $iface_ext –dport 1723 -j DNAT –to 192.168.0.x:1723
#/sbin/iptables -A PREROUTING -t nat -p 47 -i $iface_ext -j DNAT –to 192.168.0.x
## SSH Outra maquina

## RDP
#/sbin/iptables -t nat -A PREROUTING -i $iface_ext -p tcp -m tcp –dport 3389 -j DNAT –to-destination 192.168.0.x:3389
############## Testes ##########################################################
######################################################################################
###################### Bloqueio de HTTPS #############################################
######################################################################################

# Youtube / Facebook
#/sbin/iptables -I FORWARD -m string –algo bm –string “facebook.com” -j DROP
#/sbin/iptables -I FORWARD -m string –algo bm –string “youtube.com” -j DROP
#/sbin/iptables -I OUTPUT -m string –algo bm –string “facebook.com” -j DROP
#/sbin/iptables -I OUTPUT -m string –algo bm –string “youtube.com” -j DROP

################################################################################
################################# Bloqueio de entrada ##########################
################################################################################
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -i $iface_int -j ACCEPT
/sbin/iptables -A OUTPUT -p icmp –icmp-type echo-request -j ACCEPT
#/sbin/iptables -A INPUT -p icmp –icmp-type echo-reply -j ACCEPT
/sbin/iptables -A INPUT -i $iface_ext -j REJECT
## Liberar ping ## 0=on 1=off
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all

################################################################################
############################ Compartilhamento Internet #########################
################################################################################

/sbin/iptables -t nat -A POSTROUTING -o $iface_ext -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

echo “Firewall Ativado”
################################################################################
######################################## Fim ###################################
#########################################################







Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts