Junior_CvZ
(usa Ubuntu)
Enviado em 30/08/2012 - 17:51h
E ai andrecanhadas Blza?
Cara obrigado pela ajuda, consegui deixar meu firewall rodando belezinha com as regras td joia, valeu também do link que você passou para mim era tudo que eu precisa para entender o que eu queria fazer. Estou colocando aqui como ficou meu Firewall com as regras e também o acesso a vpn Matriz x Filial
ate mais cara ...
#################################################################
# #
# FIREWALL #
# #
#################################################################
#################################################################
# LIMPA REGRAS E LIBERA TODOS OS PROCESSOS DA REDE #
#################################################################
# Limpa todas as regras
echo Regras
iptables -F
iptables -t nat -F
iptables -t mangle -F
echo Limpeza das Regras ..... [ok]
################################################################
# SETAR AS REGRAS P/POSTERIORMENTE SEJE FEITO AS LIBERAÇÕES #
################################################################
echo Aceita Pacotes FORWARD que devem entrar
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Pacotes FORWARD aceitos ..... [ok]
# Coloca as polÃticas padrões como DROP, ou seja nenhum acesso foi liberado
echo Habilitando Politica Padrão
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
echo Politica Padrões Negadas ..... [ok]
################################################################
# HABILITANDO ROTEMANETO NO KERNEL E COMPARTILHANDO INTERNET #
################################################################
# Habilita o roteamento no kernel
echo Habilitando roteamento
echo 1 > /proc/sys/net/ipv4/ip_forward
echo Roteamento Habilitado ..... [ok]
# Compartilha a internet
echo Compartilhando Internet
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
echo Internet Compartilhada ..... [ok]
#################################################################
# COMPARTILHANDO VPN COM REDE INTERNA #
#################################################################
echo Compartilhando VPN
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
echo VPN Compartilhada ..... [ok]
#################################################################
# CARREGANDO MUDULOS E VARIAVEIS UTILIZADAS #
#################################################################
echo Carregando Modulos
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe nf_conntrack_ipv4
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ipt_MASQUERADE
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
/sbin/modprobe nf_nat
/sbin/modprobe nf_conntrack
/sbin/modprobe x_tables
/sbin/modprobe nf_nat_pptp
echo Modulos Carregados ..... [ok]
#CRIANDO VARIAVEIS A SEREM UTILIZADAS
echo Criando as Variaveis
IFACE_WEB="ppp0"
IFACE_LAN="eth0"
REDE_INTERNA="192.168.210.0/24"
echo Variaves Carregadas ..... [ok]
#################################################################
# CRIANDO AS REGRAS FORWARD #
#################################################################
#Libera o acesso a clientes Rede Interna
echo Liberando portas FORWARD para Rede Interna
iptables -A FORWARD -p tcp -m multiport --dports 110,587 -j ACCEPT
iptables -A FORWARD -p tcp -m multiport --sports 110,587 -j ACCEPT
iptables -A FORWARD -p udp --sport 53 -j ACCEPT
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3389 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_WEB --dport 3389 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 4899 -j ACCEPT
#iptables -A FORWARD -p tcp -i $IFACE_WEB --dport 4899 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3350 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3352 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3356 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3359 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3349 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3357 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3354 -j ACCEPT
iptables -A FORWARD -p tcp -i $IFACE_LAN --dport 3301 -j ACCEPT
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -p tcp --sport 443 -j ACCEPT
iptables -A FORWARD -p udp --dport 1194 -j ACCEPT
iptables -A FORWARD -p udp --sport 1194 -j ACCEPT
iptables -A FORWARD -d 192.168.210.0/24 -s 10.1.1.0/24 -j ACCEPT
iptables -A FORWARD -d 10.1.1.0/24 -s 192.168.210.0/24 -j ACCEPT
echo Portas FORWARD Carregadas ..... [ok]
#Fecha o Resto
echo Fechando Demais Portas FORWARD
iptables -I FORWARD -p tcp -j LOG
iptables -P FORWARD DROP
echo Portas FORWARD Fechadas ..... [ok]
#################################################################
# CRIANDO AS REGRAS INPUT #
#################################################################
#Liberando acessos INPUT
echo Aceita pacotes INPUT que devem entrar
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A INPUT -i tun0 -j ACCEPT
echo Pacotes INPUT aceitos ..... [ok]
#Liberando portas INPUT
echo Liberando portas INPUT
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --sport 443 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 1194 -j ACCEPT
iptables -t filter -A INPUT -p udp --sport 1194 -j ACCEPT
echo Portas INPUT Carregadas ..... [ok]
#Fecha o Resto
echo Fechando Demais Portas INPUT
iptables -I INPUT -p tcp -j LOG
iptables -P INPUT DROP
echo Portas INPUT Fechadas ..... [ok]
#################################################################
# CRIANDO AS REGRAS de NAT #
#################################################################
# Acesso remoto via TS para um Host Windows
echo Liberando Acesso por TS
iptables -t nat -A PREROUTING -i $IFACE_WEB -p tcp --dport 3389 -j DNAT --to-destination 192.168.210.157
echo Acesso TS Carregado ..... [ok]
# Acesso via Radmin
echo Liberando Acesso Radmin
iptables -t nat -A PREROUTING -i $IFACE_WEB -p tcp --dport 4899 -j DNAT --to-destination 192.168.210.157:4899
iptables -t nat -A PREROUTING -i $IFACE_WEB -p tcp --dport 6000 -j DNAT --to-destination 192.168.210.149
echo Acesso Radmin Carregado ..... [ok]
#Proxy Transparente
echo Proxy Transparente
iptables -t nat -A PREROUTING -i $IFACE_LAN -p tcp --dport 80 -j REDIRECT --to-port 3128
echo Proxy Transparente Carregado ..... [ok]
#################################################################
# LIBERA TRAFEGO ENTRE A VPN #
#################################################################
echo Liberando Trafego VPN
iptables -t filter -A FORWARD -p udp -s 192.168.200.0/24 --dport 1194 -j ACCEPT
iptables -t filter -A FORWARD -i tun0 -j ACCEPT
iptables -t nat -I POSTROUTING -s 10.1.1.0/24 -o eth0 -j MASQUERADE
echo Trafego Liberado ..... [ok]
#################################################################
# #
# FIM FIREWALL #
# #
#################################################################