renanalem
(usa Debian)
Enviado em 15/05/2009 - 12:34h
Então Matheu, modifiquei da forma que vc me falow tirei --dport 47 e coloquei só -p 47, e fiz igual a sua configuração, só que de cara da mensagem de erro 678, ele nem tenta ferificar o usuário e senha como estava funcionando do outro jeito que estava o meu firewall. Meu firewall completo segue abaixo.
#!/bin/bash
iniciar(){
#Inicialização de modulos
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
#Declaração das variaveis
LAN=eth0
WAN=eth3
REDE=192.168.0.0/24
#Abre para a faixa de endereço de rede local:
iptables -A INPUT -s $REDE -j ACCEPT
iptables -A INPUT -i $LAN -j ACCEPT
###################################Protecao################################
#Ignora ping
#iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
#Protege contra ping spoofing
echo > 1 /proc/sys/net/ipv4/conf/default/rp_filter
#Descarta pacotes mal formados
iptables -A INPUT -m state --state INVALID -j DROP
##################################Compartilhamento de Conexao##############
#Compartilhar a conexao
modprobe iptable_nat
echo > 1 /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
#Abre para a interface de loopback
iptables -A INPUT -p tcp -i lo -j ACCEPT
#Conectividade Social
iptables -t nat -A PREROUTING -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -A FORWARD -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -A FORWARD -p tcp -d $REDE --dport 80 -j ACCEPT
iptables -A FORWARD -p tcp -d $REDE --dport 443 -j ACCEPT
iptables -A FORWARD -p tcp -d $REDE --dport 2631 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -s 192.168.0.15 --dport 80 -d 200.201.174.0/24 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -s 192.168.0.15 --dport 443 -d 200.201.174.0/24 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -s 192.168.0.15 --dport 2631 -d 200.201.174.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.15 -d 200.201.174.0/24 --dport 80 -j MASQUERADE
iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.15 -d 200.201.174.0/24 --dport 443 -j MASQUERADE
iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.15 -d 200.201.174.0/24 --dport 2631 -j MASQUERADE
#Libera porta para outlook
iptables -A FORWARD -p TCP -s $REDE --dport 25 -j ACCEPT
iptables -A FORWARD -p TCP -s $REDE --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp --sport 25 -j ACCEPT
iptables -A FORWARD -p tcp --sport 110 -j ACCEPT
#FTP no server 192.168.0.2
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
#iptables -A FORWARD -p tcp --dport 21 -i eth1 -j ACCEPT
#iptables -t nat -A PREROUTING -p tcp --dport 21 -j DNAT --to 192.168.0.2:21
#iptables -A OUTPUT -p tcp -s 192.168.0.0/24 --dport 21 -j ACCEPT
#VPN
#iptables -i INPUT -p tcp -m tcp --dport 1723 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.71 --dport 47 -j MASQUERADE
iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.71 --dport 1723 -j MASQUERADE
iptables -A INPUT -p tcp --dport 47 -j ACCEPT
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
#iptables -A INPUT -p tcp --dport 127 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 47 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 1723 -j ACCEPT
#iptables -A OUTPUT -p tcp --dport 127 -j ACCEPT
iptables -A FORWARD -p tcp --dport 47 -i $WAN -j ACCEPT
iptables -A FORWARD -p tcp --dport 1723 -i $WAN -j ACCEPT
#iptables -A FORWARD -p tcp --dport 127 -i $WAN -j ACCEPT
iptables -A OUTPUT -p tcp -s 192.168.0.71/24 --dport 47 -j ACCEPT
iptables -A OUTPUT -p tcp -s 192.168.0.71/24 --dport 1723 -j ACCEPT
#iptables -A OUTPUT -p tcp -s 192.168.0.71/24 --dport 127 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 47 -j DNAT --to 192.168.0.71:47
iptables -t nat -A PREROUTING -p tcp --dport 1723 -j DNAT --to 192.168.0.71:1723
#iptables -t nat -A PREROUTING -p tcp --dport 127 -j DNAT --to 192.168.0.71:127
#Webserver
iptables -A OUTPUT -p tcp --dport 8080 -j ACCEPT
iptables -A FORWARD -p tcp --dport 8080 -i $WAN -j ACCEPT
iptables -A OUTPUT -p tcp -s 192.168.0.1/24 --dport 8080 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to 192.168.0.1:8080
#Bloquear msn
iptables -A FORWARD -s $REDE -p tcp --dport 1863 -j REJECT
iptables -A FORWARD -s $REDE -p tcp --dport 1080 -j REJECT
iptables -A FORWARD -s $REDE -p tcp --dport 5190 -j REJECT
#Proxy Transparente
iptables -t nat -A PREROUTING -i $REDE -p tcp -d ! 200.201.174.207 --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i $LAN -p tcp --dport 80 -j REDIRECT --to-port 3128
#Bloqueia as portas UDP de 0 a 1023:
iptables -A INPUT -p udp --dport 0:1023 -j DROP
####################################################################################
echo "REGRAS DO FIREWALL ATIVADAS"
}
parar() {
iptables -F
iptables -t nat -F
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
echo > 0 /proc/sys/net/ipv4/ip_forward
echo "REGRAS DO FIREWALL DESATIVADAS"
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
esac