tbksly
(usa Ubuntu)
Enviado em 17/04/2012 - 16:39h
Isto aí resolvido o misterio.
Obrigado aos que me ajudaram =/
#Script iptables
#Criado por Tiago Gonçalves em 02/04/12
#Atualizado por Tiago Gonçves em 12/04/12
echo setando Variaveis de ambiente
REDESL="192.168.2.0/24"
REDEPOA="10.20.31.0/24"
echo Limpando regras
iptables -X
iptables -Z
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -F -t nat
iptables -F -t mangle
echo Alterando politicas para DROP
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
echo Iniciando regras de liberaç
echo Liberando conexoes estabelecidas e relacionadas
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Aceita todo o trafego vindo do loopback e indo pro loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
echo Libera acesso ao FW por SSH para rede interna
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
echo Libera portas VPN
iptables -A INPUT -p tcp --dport 47 -j ACCEPT
iptables -A INPUT -p udp --dport 47 -j ACCEPT
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -p udp --dport 1723 -j ACCEPT
echo Habilita as portas do IPSEC #retirado do site
http://www.vivaolinux.com.br/artigo/VPN-com-Openswan-e-Iptables-%28fazendo-NAT%29?pagina=2
iptables -A INPUT -p udp --sport 500 --dport 500 -j ACCEPT
iptables -A OUTPUT -p udp --sport 500 --dport 500 -j ACCEPT
iptables -A INPUT -p 50 -j ACCEPT
iptables -A OUTPUT -p 50 -j ACCEPT
iptables -A INPUT -p 51 -j ACCEPT
iptables -A OUTPUT -p 51 -j ACCEPT
iptables -A INPUT -p tcp --sport 2020 --dport 2020 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 2020 --dport 2020 -j ACCEPT
echo Libera ping para o FW
iptables -A INPUT -p icmp -j ACCEPT
echo Libera ping para rede interna
iptables -A FORWARD -s $REDESL -p icmp -j ACCEPT
echo Libera rede interna a acessar o FW
iptables -A INPUT -s $REDESL -j ACCEPT
iptables -A INPUT -s $REDEPOA -j ACCEPT
echo libera saida pela VPN
#iptables -A FORWARD -i eth2 -p tcp -d $REDESL --dport 1723 -j ACCEPT
#iptables -A FORWARD -o eth2 -p tcp -s $REDESL --sport 1723 -j ACCEPT
#iptables -A FORWARD -i eth2 -p 47 -d $REDESL -j ACCEPT
#iptables -A FORWARD -o eth2 -p 47 -s $REDESL -j ACCEPT
iptables -t filter -I FORWARD -s $REDESL -d $REDEPOA -j ACCEPT
iptables -t filter -I FORWARD -s $REDEPOA -d $REDESL -j ACCEPT
echo Libera roteamento para rua na ADSL EXCETO saida para VPN
iptables -t nat -A POSTROUTING ! -d $REDEPOA -s $REDESL -j MASQUERADE
# Liberando Porta 21 (ftp)
iptables -A FORWARD -s $REDESL -p udp --dport 21 -j ACCEPT
iptables -A FORWARD -s $REDESL -p udp --dport 20 -j ACCEPT
# Liberando porta 53 (DNS)
iptables -A FORWARD -s $REDESL -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -s $REDESL -p udp --dport 53 -j ACCEPT
# Liberando porta 80 (DNS)
iptables -A FORWARD -s $REDESL -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -s $REDESL -p udp --dport 80 -j ACCEPT