erikogp
(usa Debian)
Enviado em 04/02/2011 - 09:41h
Estou com um problema com o messenger 2011. Aqui na minha empresa o firewall está bloqueando conexões ao msn 2011. É só com essa versão. Ele não deixa ele conectar de jeito nenhum. Lembrando que é só o msn 2011 que ele bloqueia. Não é controle de acesso, pois minha conta tem acesso irrestrito. No msn 2009 conecta de boa. Daí como agora é obrigatório, todos usuários na empresa com windows vista e seven estão sem acessar msn por causa disso. Com o comando:
tail -f /var/log/squid/access.log |grep 192.168.157.197 vi a seguinte mensagem de erro na tentativa de conexão:
192.168.157.197 TCP_DENIED/400 1195 NONE error:unsupported-request-method - NONE/- text/html
É esse o erro que aparece. Falei com um amigo meu e ele disse que eu teria que criar uma regra no iptables para liberar o acesso. Já inseri todas que encontrei na net, mas nenhuma deu certo. O versão do meu sistema é um debian.
Este é o script do meu firewall.
Até o momento tudo funciona absolutamente normal. Consigo acesso a qualquer site, abro outlook, faço qualquer download. Só mesmo o msn 2011 que é barrado. Penso que não seja no squid, pois meu IP no squid está para não entrar em nenhuma regra. Nenhuma regra do squid se aplica ao meu IP.
Troquei alguns IP's por (ip) de propósito só para postar aqui.
#!/bin/bash
# firewall
# variaveis
EXTERNA="eth0";
INTERNA="eth9";
REDE="192.168.157.0/24";
LOOPBACK="lo";
IPTABLES=`which iptables`;
BROADCAST="127.0.0.0/255.0.0.0";
ECHOA=0;
LOGFILE="/var/log/firewall.log"
fw_start()
{
if [ $ECHOA == 0 ]; then
echo "Inicializando o Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`"
echo "--------------------------------------------------" >> $LOGFILE
echo "Inicializando o Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`" >> $LOGFILE
fi
#carrega modulos
echo "Carregando modulo iptable_nat."
echo "Carregando modulo iptable_nat." >> $LOGFILE
modprobe iptable_nat
echo "Carregando modulo ip_conntrack."
echo "Carregando modulo ip_conntrack." >> $LOGFILE
modprobe ip_conntrack
echo "Carregando modulo ip_conntrack_ftp."
echo "Carregando modulo ip_conntrack_ftp." >> $LOGFILE
modprobe ip_conntrack_ftp
echo "Carregando modulo ip_nat_ftp."
echo "Carregando modulo ip_nat_ftp." >> $LOGFILE
modprobe ip_nat_ftp
#ativa o roteamento
echo "Ativando o roteamento."
echo "Ativando o roteamento." >> $LOGFILE
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Ativando rp_filter."
echo "Ativando rp_filter." >> $LOGFILE
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo 0 > $f
done
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
#politica padrao
###############################################
echo "Ativando politica padrao."
echo "Ativando politica padrao." >> $LOGFILE
$IPTABLES -t filter -P INPUT DROP
$IPTABLES -t filter -P FORWARD DROP
$IPTABLES -t filter -P OUTPUT ACCEPT
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
# Spoofing...
###############################################
echo "Ativando regra contra Spoofing."
echo "Ativando regra contra Spoofing." >> $LOGFILE
$IPTABLES -A PREROUTING -t nat -i $EXTERNA -s 192.168.0.0/16 -j DROP
$IPTABLES -A PREROUTING -t nat -i $EXTERNA -s 172.16.0.0/12 -j DROP
$IPTABLES -A PREROUTING -t nat -i $EXTERNA -s 10.0.0.0/8 -j DROP
#cria chain com regras de segurança
###############################################
# echo "Criando chain com regras de seguranca."
# echo "Criando chain com regras de seguranca." >> $LOGFILE
# $IPTABLES -N BLOCK
# $IPTABLES -A BLOCK -p icmp --icmp-type echo-request -j DROP
# $IPTABLES -A BLOCK -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
# $IPTABLES -A BLOCK -p tcp -m limit --limit 1/s -j ACCEPT
# $IPTABLES -A BLOCK -p tcp --tcp-flags SYN,ACK,FIN,RST SYN -m limit --limit 1/s -j ACCEPT
# $IPTABLES -A BLOCK -m unclean -j DROP
# $IPTABLES -A BLOCK -m state --state ESTABLISHED,RELATED -j ACCEPT
## $IPTABLES -A BLOCK -j LOG --log-prefix "FW_ALERT: "
# $IPTABLES -A BLOCK -j DROP
#Libera todo o trafego local
###############################################
echo "Liberando o trafego local."
echo "Liberando o trafego local." >> $LOGFILE
# $IPTABLES -t filter -A INPUT -i $LOOPBACK -s $BROADCAST -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p tcp --syn -s $BROADCAST -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p udp --syn -s $BROADCAST -j ACCEPT
$IPTABLES -t filter -A INPUT -i $LOOPBACK -j ACCEPT
$IPTABLES -t filter -A INPUT -i $INTERNA -j ACCEPT
$IPTABLES -t filter -A FORWARD -i $INTERNA -j ACCEPT
#Regra de teste para liberar msn
###############################################
echo "Liberar msn 2011"
$IPTABLES -I FORWARD -p tcp -s 192.168.157.197 --dport 1863 -j ACCEPT
# Compartilhamento da Internet
###############################################
echo "Liberando compartilhamento da Internet."
echo "Liberando compartilhamento da Internet." >> $LOGFILE
$IPTABLES -t nat -A POSTROUTING -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -o $EXTERNA -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -s $REDE -o $EXTERNA -j MASQUERADE
# NAT da rede interna
###############################################
echo "Liberando NAT da rede interna."
echo "Liberando NAT da rede interna." >> $LOGFILE
$IPTABLES -A POSTROUTING -t nat -o $EXTERNA -s $REDE -j SNAT --to (ip)
# Controle de trafego reverso da internet
###############################################
echo "Liberando controle de trafego reverso de internet."
echo "Liberando controle de trafego reverso de internet." >> $LOGFILE
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $EXTERNA -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $INTERNA -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#Libera FIREBIRD
###############################################
echo "Liberando FIREBIRD."
echo "Liberando FIREBIRD." >> $LOGFILE
$IPTABLES -t filter -A INPUT -i $INTERNA -p tcp --dport 3050 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p tcp --dport 3050 -j ACCEPT
#Libera FTP,TELNET
###############################################
echo "Liberando FTP e TELNET."
echo "Liberando FTP e TELNET." >> $LOGFILE
$IPTABLES -t filter -A INPUT -i $EXTERNA -p tcp -m multiport --dports 20,21,22,23 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p tcp -m multiport --dports 20,21,22,23 -j ACCEPT
#Libera Porta 8080 Apache
###############################################
echo "Liberando Apache na porta 8080."
echo "Liberando Apache na porta 8080." >> $LOGFILE
$IPTABLES -t filter -A INPUT -p tcp --dport 8080 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p tcp --dport 8080 -j ACCEPT
#Libera Porta 53,953 Bind
###############################################
echo "Liberando Bind nas portas 53,953."
echo "Liberando Bind nas portas 53,953." >> $LOGFILE
$IPTABLES -t filter -A INPUT -p tcp -m multiport --dports 53,953 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p tcp -m multiport --dports 53,953 -j ACCEPT
$IPTABLES -t filter -A INPUT -p udp -m multiport --dports 53,953 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p udp -m multiport --dports 53,953 -j ACCEPT
#Libera Porta 631 - CUPS
###############################################
echo "Liberando CUPS na porta 631."
echo "Liberando CUPS na porta 631." >> $LOGFILE
$IPTABLES -t filter -A INPUT -p tcp --dport 631 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p tcp --dport 631 -j ACCEPT
$IPTABLES -t filter -A INPUT -p udp --dport 631 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p udp --dport 631 -j ACCEPT
#Libera Porta 3306 - MySQL
###############################################
echo "Liberando MySQL na porta 3306."
echo "Liberando MySQL na porta 3306." >> $LOGFILE
$IPTABLES -t filter -A INPUT -p tcp --dport 3306 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p tcp --dport 3306 -j ACCEPT
$IPTABLES -t filter -A INPUT -p udp --dport 3306 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p udp --dport 3306 -j ACCEPT
#Libera POP3, SMTP, IMAP E FREEPOP
###############################################
echo "Liberando POP3, SMTP, IMAP E FREEPOPs."
echo "Liberando POP3, SMTP, IMAP E FREEPOPs." >> $LOGFILE
$IPTABLES -t filter -A INPUT -i $EXTERNA -p tcp -m multiport --dports 110,143,25,2000 -j ACCEP
T
$IPTABLES -t filter -A OUTPUT -p tcp -m multiport --dports 110,143,25,2000 -j ACCEPT
#Libera REMOTE DESKTOP (NAT)
###############################################
echo "Liberando e redirencionando REMOTE DESKTOP."
echo "Liberando e redirencionando REMOTE DESKTOP." >> $LOGFILE
$IPTABLES -t nat -A PREROUTING -p tcp -s 0/0 --dport 3389 -i $EXTERNA -j DNAT --to-destination (ip):3389
$IPTABLES -t nat -A PREROUTING -p tcp -s 0/0 --dport 3389 -i $INTERNA -j DNAT --to-destination (ip):3389
$IPTABLES -A FORWARD -p tcp -i $EXTERNA -d (ip) --dport 3389 -j ACCEPT
#Libera PORTMAP, MOUNTD, NFSD
###############################################
echo "Liberando PORTMAP, MOUNTD E NFSD."
echo "Liberando PORTMAP, MOUNTD E NFSD." >> $LOGFILE
$IPTABLES -t filter -A INPUT -i $INTERNA -p tcp -m multiport --dports 111,745,747,2049 -j ACCE
PT
$IPTABLES -t filter -A INPUT -i $INTERNA -p udp -m multiport --dports 111,745,747,2049 -j ACCE
PT
$IPTABLES -t filter -A OUTPUT -p tcp -m multiport --dports 111,745,747,2049 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p udp -m multiport --dports 111,745,747,2049 -j ACCEPT
#Redireciona internet para PROXY
###############################################
echo "Redirecionando internet para o PROXY."
echo "Redirecionando internet para o PROXY." >> $LOGFILE
$IPTABLES -t nat -A PREROUTING -p tcp -m multiport -s $REDE --dports 80,443 -j REDIRECT --to-p
ort 3128
#Forca fechamento da porta 80 (HTTP)
###############################################
# echo "Forcando fechamento da porta 80."
# echo "Forcando fechamento da porta 80." >> $LOGFILE
#$IPTABLES -A FORWARD -p tcp --dport 80 -j REJECT
#Regras para evitar packet flood
###############################################
# $IPTABLES -A INPUT -j BLOCK
# $IPTABLES -A FORWARD -j BLOCK
}
fw_stop()
{
if [ $ECHOA == 0 ]; then
echo "Finalizando o Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`"
echo "Finalizando o Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`" >> $LOGFILE
fi
$IPTABLES -t filter -P INPUT ACCEPT
$IPTABLES -t filter -P FORWARD ACCEPT
$IPTABLES -t filter -P OUTPUT ACCEPT
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
$IPTABLES -t filter -F
$IPTABLES -t nat -F
$IPTABLES -t filter -X
$IPTABLES -t nat -X
$IPTABLES -t filter -Z
$IPTABLES -t nat -Z
}
fw_usage()
{
echo
echo "$0 (start | stop | restart | clear)"
echo
echo "start - Ativa o firewall"
echo "stop - Desativa o firewall"
echo "restart - Reativa o firewall"
echo "clear - Limpa os contadores"
}
fw_clear()
{
echo "Limpando os contadores do Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`"
echo "--------------------------------------------------" >> $LOGFILE
echo "Limpando os contadores do Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`" >> $LOGFILe
$IPTABLES -t filter -Z
$IPTABLES -t nat -Z
}
case "$1" in
start)
fw_start
;;
stop)
fw_stop
;;
restart)
ECHOA=1
echo "Reinicializando o Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`"
echo "--------------------------------------------------" >> $LOGFILE
echo "Reinicializando o Firewall em `date \"+%d/%b (%a) - %H:%M:%S\"`" >> $LOGFILe
fw_stop;
fw_start
;;
clear)
fw_clear
;;
*)
fw_usage;
exit
;;
esac