rensantos
(usa Ubuntu)
Enviado em 02/03/2015 - 13:32h
buckminster escreveu:
Tem firewall na rede (Iptables)?
Tente fazer o acesso sem passar pelo proxy, se conseguir, o problema é com o Squid.
Verifique tabmém se o problema não é com o Itaú. Às vezes eles bloqueiam determinado IP ou blocos de IPs devido a acessos indevidos.
Olá buckminster,
Tem sim, veja como é meu firewall:
#! /bin/sh
# Firewall System
#
internet="eth0"
redelocal="eth1"
echo "###################ATIVANDO IPTABLES#######################"
### Passo 1: Limpando as regras ###
/sbin/iptables -F INPUT
/sbin/iptables -F OUTPUT
/sbin/iptables -F FORWARD
/sbin/iptables -F POSTROUTING -t nat
/sbin/iptables -F PREROUTING -t nat
/sbin/iptables -F -t nat
echo "Limpando as regras ..................................[ OK ]"
# Definindo a Politica Default das Cadeias
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT ACCEPT
echo "Politica Default das Cadeias ........................[ OK ]"
### Passo 2: Desabilitar o trafego IP entre as placas de rede ###
echo "0" > /proc/sys/net/ipv4/ip_forward
echo "Desabilitar o trafego IP entre as placas ............[ OK ]"
# Configurando a Protecao anti-spoofing - Default = 0
echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
#for spoofing in /proc/sys/net/ipv4/conf/*/rp_filter; do
# echo "1" > $spoofing
#done
echo "Protecao anti-spoofing ..............................[ OK ]"
# Impedimos que um atacante possa maliciosamente alterar alguma rota - Default = 0
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
echo "Impedimos alterar alguma rota .......................[ OK ]"
# Utilizado em diversos ataques, isso possibilita que o atacante determine o "caminho" que seu
# pacote vai percorrer (roteadores) ate seu destino. Junto com spoof, isso se torna muito perigoso. - Default = 0
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
echo "Impossibilita que o atacante determine o "caminho" ....[ OK ]"
# Protecao contra responses bogus - Default = 0
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo "Protecao contra responses bogus .....................[ OK ]"
# Protecao contra ataques de syn flood (inicio da conexao TCP). Tenta conter ataques de DoS. - Default = 1
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo "Protecao contra ataques de syn ......................[ OK ]"
### Passo 3: Carregando os modulos do /sbin/iptables ###
# Ativa modulos
# -------------------------------------------------------
/sbin/modprobe iptable_nat
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_REJECT
/sbin/modprobe ipt_MASQUERADE
echo "Carregando os modulos ...............................[ OK ]"
#################################################
# FIM DA Tabela FILTER
#################################################
# Proteção contra port scanners
/sbin/iptables -N SCANNER
/sbin/iptables -A SCANNER -m limit --limit 15/m -j LOG --log-prefix "FIREWALL: port scanner: "
/sbin/iptables -A SCANNER -j DROP
/sbin/iptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -i $internet -j SCANNER
/sbin/iptables -A INPUT -p tcp --tcp-flags ALL NONE -i $internet -j SCANNER
/sbin/iptables -A INPUT -p tcp --tcp-flags ALL ALL -i $internet -j SCANNER
/sbin/iptables -A INPUT -p tcp --tcp-flags ALL FIN,SYN -i $internet -j SCANNER
/sbin/iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -i $internet -j SCANNER
/sbin/iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -i $internet -j SCANNER
/sbin/iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -i $internet -j SCANNER
echo "Scaner de Portas ....................................[ OK ]"
# Protecao contra acesso externo squid
/sbin/iptables -A INPUT -p TCP -i $internet --dport 3128 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 8080 -j DROP
echo "Proteção contra squid externo........................[ OK ]"
# Liberando tráfego do túnel
/sbin/iptables -A FORWARD -i tun0 -j ACCEPT
/sbin/iptables -A INPUT -i tun0 -j ACCEPT
/sbin/iptables -A FORWARD -i tun1 -j ACCEPT
/sbin/iptables -A INPUT -i tun1 -j ACCEPT
echo "Liberando trafego nos tuneis.........................[ OK ]"
#Traceroutes caindo
/sbin/iptables -A INPUT -p udp --dport 33434:33523 -j DROP
/sbin/iptables -A INPUT -p tcp --dport 113 -j REJECT
/sbin/iptables -A INPUT -p igmp -j REJECT
#/sbin/iptables -A INPUT -p tcp --dport 80 -j DROP
#/sbin/iptables -A INPUT -p tcp --dport 443 -j REJECT
echo "Rejeitando lixo :....................................[ OK ]"
#alterando prioridades via TOS
/sbin/iptables -t mangle -A FORWARD -i eth1 -p udp -j TOS --set-tos 8
/sbin/iptables -t mangle -I FORWARD -i eth1 -p udp -j DSCP --set-dscp 8
#/sbin/iptables -t mangle -A FORWARD -p tcp --dport 80 -j DSCP --set-dscp-class EF - Nao testado
/sbin/iptables -t mangle -A OUTPUT -o eth0 -p udp -j TOS --set-tos 8
/sbin/iptables -t mangle -A PREROUTING -i eth0 -p udp -j TOS --set-tos 8
/sbin/iptables -t mangle -A POSTROUTING -o eth0 -p udp -j DSCP --set-dscp 8
/sbin/iptables -t mangle -I OUTPUT -p udp -j DSCP --set-dscp 8
echo "Alterando TOS proto UDP..............................[ OK ]"
#liberando portas
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 10000 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 10000 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 82 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 82 -j ACCEPT
echo "Liberando port 80....................................[ OK ]"
#portas para departamento pessoal
#sefip
/sbin/iptables -A FORWARD -p tcp --dport 2004 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 2631 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 1494 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 5017 -j ACCEPT
#/sbin/iptables -A FORWARD -p tcp -s 10.0.0.x --dport 9090 -j ACCEPT
echo "Regras DP ...........................................[ OK ]"
#VoIP
/sbin/iptables -A FORWARD -p udp --dport 5060 -j ACCEPT
/sbin/iptables -A INPUT -p udp --dport 5060 -j ACCEPT
#cadastro
/sbin/iptables -A FORWARD -p tcp --dport 25777 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 5432 -j ACCEPT
#qlickview
/sbin/iptables -A FORWARD -p tcp --dport 1433 -j ACCEPT
echo "Regras QlickView ....................................[ OK ]"
##Algumas portas
/sbin/iptables -A FORWARD -p tcp --dport 1434 -j ACCEPT
echo "Regras para SQL Manag. Std. .........................[ OK ]"
#terminal server
/sbin/iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 3389 -j ACCEPT
echo "Regras terminal serv ................................[ OK ]"
#zabbix
/sbin/iptables -A INPUT -p tcp --dport 10050 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 10050 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 10051 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 10051 -j ACCEPT
echo "Regras Zabbix .......................................[ OK ]"
#vpn
/sbin/iptables -A INPUT -p tcp --dport 30001 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 30001 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 30002 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 30002 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 30003 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 30003 -j ACCEPT
echo "Regras VPN ..........................................[ OK ]"
######
######
# PORTA 3128 - ACEITA PARA A REDE LOCAL
/sbin/iptables -A FORWARD -i $redelocal -p tcp --dport 3128 -j ACCEPT
# Redireciona porta 80 para 3128 (squid)
#/sbin/iptables -t nat -A PREROUTING -i $redelocal -p tcp --dport 80 -j REDIRECT --to-port 3128
/sbin/iptables -t nat -A PREROUTING -p tcp -s 10.0.0.0/24 --dport 80 -j DNAT --to-destination 10.0.0.1:3128
# PORTA 53 - ACEITA PARA A REDE LOCAL
/sbin/iptables -A FORWARD -i $redelocal -p tcp --dport 53 -j ACCEPT
/sbin/iptables -A FORWARD -i $redelocal -p udp --dport 53 -j ACCEPT
# PORTA 110 - ACEITA PARA A REDE LOCAL
/sbin/iptables -A FORWARD -i $redelocal -p tcp --dport 110 -j ACCEPT
/sbin/iptables -A FORWARD -i $redelocal -p udp --dport 110 -j ACCEPT
# PORTA 25 - ACEITA PARA A REDE LOCAL
/sbin/iptables -A FORWARD -i $redelocal -p tcp --dport 25 -j ACCEPT
# identd
/sbin/iptables -A INPUT -p tcp --dport 113 -j ACCEPT
/sbin/iptables -A INPUT -p udp --dport 113 -j ACCEPT
# E-mail (smtp, imap, pop, popssl, ...)
/sbin/iptables -A INPUT -p tcp --dport 587 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 587 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 465 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 465 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 25 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 25 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 993 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 993 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 995 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 995 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 110 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 110 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 143 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 143 -j ACCEPT
echo "Regras para E-mail ..................................[ OK ]"
# https
/sbin/iptables -A INPUT -p tcp --dport 443 -j ACCEPT
/sbin/iptables -A INPUT -p udp --dport 443 -j ACCEPT
/sbin/iptables -A FORWARD -i $redelocal -p tcp --dport 443 -j ACCEPT
# PORTA 20 - ACEITA PARA A REDE LOCAL
/sbin/iptables -A FORWARD -p tcp --dport 20 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --syn --dport 22 -m recent --name sshattack --set
/sbin/iptables -A INPUT -p tcp --dport 22 --syn -m recent --name sshattack --rcheck --seconds 60 --hitcount 3 -j LOG --log-prefix 'SSH REJECT: '
/sbin/iptables -A INPUT -p tcp --dport 22 --syn -m recent --name sshattack --rcheck --seconds 60 --hitcount 3 -j REJECT --reject-with tcp-reset
/sbin/iptables -A FORWARD -p tcp --syn --dport 22 -m recent --name sshattack --set
/sbin/iptables -A FORWARD -p tcp --dport 22 --syn -m recent --name sshattack --rcheck --seconds 60 --hitcount 3 -j LOG --log-prefix 'SSH REJECT: '
/sbin/iptables -A FORWARD -p tcp --dport 22 --syn -m recent --name sshattack --rcheck --seconds 60 --hitcount 3 -j REJECT --reject-with tcp-reset
# PORTA 21 - ACEITA PARA A REDE LOCAL
/sbin/iptables -A INPUT -p tcp --dport 21 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 21 -j ACCEPT
# PORTA 22 - ACEITA PARA A REDE INTERNET
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 22 -j ACCEPT
###vpn criar estas regras para todas vpns
/sbin/iptables -A INPUT -p tcp --dport 5001 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --dport 5001 -j ACCEPT
/sbin/iptables -A INPUT -p udp --dport 5001 -j ACCEPT
/sbin/iptables -A FORWARD -p udp --dport 5001 -j ACCEPT
/sbin/iptables -I FORWARD -i tun0 -j ACCEPT
/sbin/iptables -I FORWARD -o tun0 -j ACCEPT
#########################
#bloqueia qualquer tentativa de nova conexao de fora para esta maquina
#/sbin/iptables -A INPUT -i $internet -m state ! --state ESTABLISHED,RELATED -j LOG --log-level 6 --log-prefix "FIREWALL entrada "
/sbin/iptables -A INPUT -i $internet -m state ! --state ESTABLISHED,RELATED -j DROP
#no /sbin/iptables, temos de dizer quais sockets sao validos em uma conexao
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
echo "Cadeia de Entrada ...................................[ OK ]"
################################
# Cadeia de Reenvio (FORWARD).
# Primeiro, ativar o mascaramento (nat).
/sbin/iptables -t nat -F POSTROUTING
/sbin/iptables -t nat -A POSTROUTING -o $internet -j MASQUERADE
echo "Ativando o mascaramento .............................[ OK ]"
# Agora dizemos quem e o que podem acessar externamente
# O controle do acesso a rede externa e feito na cadeia "FORWARD"
/sbin/iptables -A FORWARD -i $internet -j ACCEPT
/sbin/iptables -A FORWARD -o $internet -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "Ativando o acesso ftp.. .............................[ OK ]"
## Liberando para VPN (protocolo ICMP)
/sbin/iptables -A FORWARD -p icmp -d 192.168.254.0/24 -j ACCEPT
###################
###BLOQUEANDO TODAS AS SAIDAS E PORTAS
/sbin/iptables -A INPUT -p all -j DROP
/sbin/iptables -A FORWARD -p all -j DROP
echo "Rejeitando saida e entrada ..........................[ OK ]"
########################
# No iptables, temos de dizer quais sockets sao validos em uma conexao
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
echo "Quais sockets sao validos ...........................[ OK ]"
#################################################
# Tabela FILTER
#################################################
# Proteção contra tronjans
# -------------------------------------------------------
/sbin/iptables -A INPUT -p TCP -i $internet --dport 666 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 4000 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 6000 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 6006 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 16660 -j DROP
# Proteção contra trinoo
# -------------------------------------------------------
/sbin/iptables -A INPUT -p TCP -i $internet --dport 27444 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 27665 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 31335 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 34555 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 35555 -j DROP
echo "Proteção contra trinoo ..............................[ OK ]"
# Protecao contra acesso externo squid
/sbin/iptables -A INPUT -p TCP -i $internet --dport 3128 -j DROP
/sbin/iptables -A INPUT -p TCP -i $internet --dport 8080 -j DROP
echo "Proteção contra squid externo........................[ OK ]"
# Protecao contra telnet
/sbin/iptables -A INPUT -p TCP -i $internet --dport telnet -j DROP
echo "Proteção contra telnet ..............................[ OK ]"
# Dropa pacotes TCP indesejaveis
/sbin/iptables -A FORWARD -p tcp ! --syn -m state --state NEW -j DROP
# Protecao contra worms
/sbin/iptables -A FORWARD -p tcp --dport 135 -i $internet -j REJECT
# Protecaocontra syn-flood
/sbin/iptables -A FORWARD -p tcp --syn -m limit --limit 2/s -j ACCEPT
# Protecao contra ping da morte
/sbin/iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
#Allow ALL other forwarding going out
/sbin/iptables -A FORWARD -o $internet -i $redelocal -j ACCEPT
echo "Caregado tabela filter ..............................[ OK ]"
# Finalmente: Habilitando o trafego IP, entre as Interfaces de rede
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "Habilitar o trafego IP entre as placas: .............[ OK ]"
## Bloqueio Facebook
for i in `cat /etc/firewall/filters/ipsface_bloqueados` ; do
/sbin/iptables -I FORWARD -s $i -m string --algo bm --string "facebook.com" -m time --timestart 07:00 --timestop 12:00 --kerneltz -j REJECT
/sbin/iptables -I OUTPUT -s $i -m string --algo bm --string "facebook.com" -m time --timestart 07:00 --timestop 12:00 --kerneltz -j REJECT
/sbin/iptables -I FORWARD -s $i -m string --algo bm --string "facebook.com" -m time --timestart 13:00 --timestop 22:00 --kerneltz -j REJECT
/sbin/iptables -I OUTPUT -s $i -m string --algo bm --string "facebook.com" -m time --timestart 13:00 --timestop 22:00 --kerneltz -j REJECT
/sbin/iptables -I FORWARD -s $i -m string --algo bm --string "youtube.com" -m time --timestart 07:00 --timestop 12:00 --kerneltz -j REJECT
/sbin/iptables -I OUTPUT -s $i -m string --algo bm --string "youtube.com" -m time --timestart 07:00 --timestop 12:00 --kerneltz -j REJECT
/sbin/iptables -I FORWARD -s $i -m string --algo bm --string "youtube.com" -m time --timestart 13:00 --timestop 22:00 --kerneltz -j REJECT
/sbin/iptables -I OUTPUT -s $i -m string --algo bm --string "youtube.com" -m time --timestart 13:00 --timestop 22:00 --kerneltz -j REJECT
done
## Bloqueio Whatsapp
/etc/firewall/filters/whatsapp.sh
echo "##################FIM DE REGRAS IPTABLES###################"
exit 0
Nos ips para o firewall eu coloquei vários ips aqui da rede e o script do Whatsapp está assim:
#!/bin/bash
# Bloqiueia IPs Whatsapp
for i in `cat /etc/firewall/filters/ips_whatsapp`
do
iptables -I INPUT -s $i -j DROP
iptables -I FORWARD -d $i -j DROP
done
E os ips são esses do whatsapp
173.192.0.0/15
184.172.0.0/15
174.36.0.0/15
Tem alguma coisa errada nele?