Página 3 de 3 PrimeiroPrimeiro 123
+ Responder ao Tópico



  1. Citação Postado originalmente por Luzumba
    Olha só quer que eu mande o conf do meu firewall ? qqr. coisa me ache no msn, ok ?
    ai te passo o meu conf.
    Abraços
    Posta no forum... ai mais gente já aprende tb...

  2. #12
    Luzumba
    Rs...
    é que é meio grandinho ... rs...
    Ma la vai
    Olha só gente não é vergonha naum mas é que tem um monte de linha que eu nao apaguei por isso me desculpa ai heim se alguem nao entender rs...

    Um beijo a todos

    ===========

    #!/bin/bash

    # Ativa o Roteamento
    echo 'Roteamento ativado'

    echo 1 > /proc/sys/net/ipv4/ip_forward

    # variaves do sistema
    REDE0=`LC_ALL= LANG= /sbin/ifconfig eth1 | grep "inet addr:" | sed 's/.*inet addr://' | cut -d ' ' -f 1`
    REDE1='192.168.0.0/24'
    REDE2='192.168.1.0/24'
    IPWWW='64.191.29.2'


    # IPS Servidores
    ZEUS='192.168.0.1'
    GATEWAY='192.168.0.254'

    # IPS confiaveis
    MARIO='192.168.0.246'
    ADRIANO='192.168.0.216'


    #Limpa Regras nas tabelas Filters e NAT
    echo 'Limpando Regras Filter e NAT'
    iptables -F
    iptables -F -t nat

    ### Modulos para permitir uso de FTP
    echo 'Modulos FTP metodo Passivo'
    # depmod -a
    modprobe ip_conntrack_ftp
    modprobe ip_nat_ftp
    ######

    #Define as Políticas
    echo 'Definindo Politicas'
    iptables -P INPUT DROP
    iptables -P FORWARD DROP
    iptables -P OUTPUT DROP
    ##########

    #Cria mascaramento da rede interna com a Internet
    #iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
    echo 'Criando Regra para Redirecionamento'
    iptables -t nat -A POSTROUTING -o eth1 -s $REDE1 -j SNAT --to-source $REDE0
    ##################

    # Usuarios Acima de tudo
    echo 'Liberando Usuarios Diretores'
    iptables -A FORWARD -s $MARIO -j ACCEPT
    iptables -A FORWARD -s $ADRIANO -j ACCEPT

    ##################################
    # Permite comunicação com servidores DNS na Internet
    echo 'Permitindo Comunicao com DNS'
    #Requisição
    iptables -A FORWARD -p udp -s $REDE1 --sport 1024: -d 0/0 --dport 53 -j ACCEPT
    #Resposta
    iptables -A FORWARD -p udp -s 0/0 --sport 53 -d $REDE1 --dport 1024: -j ACCEPT
    ###############

    #Permite comunicação com protocolo HTTP

    #Requisição
    #iptables -A FORWARD -p tcp -s 192.168.0.0/24 -i eth1 --sport 1024: -d 0/0 -o eth0 --dport 80 -j ACCEPT
    #Resposta
    #iptables -A FORWARD -p tcp -s 0/0 -i eth0 --sport 80 -d 192.168.0.0/24 -o eth1 --dport 1024: -j ACCEPT
    #########################################################

    # Permite a abertura da Porta (6891) Msn no Kopete
    # Saida
    echo 'Permite a abertura da porta 6891 MSN - Kopete'
    # Requisicao
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 6891 -j ACCEPT
    # Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 6891 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    #########################################################

    #Permite comunicação com protocolo HTTPS
    echo 'Permitindo comunicacao com HTTPS'
    #Requisição
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 443 -j ACCEPT
    #Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 443 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT


    #Permite comunicação de FTP
    echo 'Permitindo comunicacao com FTP'
    #Requisição
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 20:21 -j ACCEPT
    iptables -A FORWARD -p udp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 20:21 -j ACCEPT
    #Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 20:21 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    iptables -A FORWARD -p udp -s 0/0 -i eth1 --sport 20:21 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    #################


    #Permite a Rede Local pingar na Internet
    echo 'Permitindo Rede Local Pingar na Internet'
    #Requisição
    iptables -A FORWARD -p icmp --icmp-type ping -s $REDE1 -i eth0 -d 0/0 -o eth1 -j ACCEPT
    #Resposta
    iptables -A FORWARD -p icmp --icmp-type pong -s 0/0 -i eth1 -d $REDE1 -o eth0 -j ACCEPT
    #####################

    #Permite a Rede Local pingar o Firewall
    echo 'Permitindo Rede Local Pingar Firewall'
    #Requisição
    iptables -A INPUT -p icmp --icmp-type ping -s $REDE1 -i eth0 -d $ZEUS -j ACCEPT
    #Resposta
    iptables -A OUTPUT -p icmp --icmp-type pong -s $ZEUS -o eth0 -d $REDE1 -j ACCEPT
    #####################

    # Permite a Rede Local accear a porta 1240 Globaltrack
    echo 'Libera porta para o Global Track'
    # Requisicao
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 1240 -j ACCEPT
    # Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 1240 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ##############################

    # Permite a Rede Local acessar a porta 23 no Site Pool
    echo 'Libera porta para TelNet'
    #Requisicao
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d $IPWWW -o eth1 --dport 23 -j ACCEPT
    # Resposta
    iptables -A FORWARD -p tcp -s $IPWWW -i eth1 --sport 23 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ############################

    #Permite a Rede Local acessar um servidor POP3 na Internet
    echo 'Permitindo Rede Local Acessar POP3'
    #Requisição
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 110 -j ACCEPT
    #Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 110 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ####################################

    # Permite a Rede Local acessar a porta 2095, 2086, 2082 dominios pool
    echo 'Permitindo Rede Local Acessar Portas Dominio avitual'
    # Requisicao
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 2095 -j ACCEPT
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 2086 -j ACCEPT
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 2082 -j ACCEPT
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d $IPWWW -o eth1 --dport 48603 -j ACCEPT

    # Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 2095 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 2086 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 2082 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    iptables -A FORWARD -p tcp -s $IPWWW -i eth1 --sport 48603 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ##################################


    #Permite a Rede Local acessar um servidor SMTP na Internet
    echo 'Permitindo Rede Local Acessar SMTP'
    #Requisição
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 25 -j ACCEPT
    #Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 25 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    #######################################
    #echo 'Permitindo Rede Local Acessar ICQ'
    #Permite a Rede Local accessar o ICQ pela porta 5190 na Internet
    # saida
    #iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 5190 -j ACCEPT
    # Resposta
    #iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 5190 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ########################################
    echo 'Permitindo a Rede Local Acessar o MSN'
    # Pemite a Rede Local accessar o MSN pela porta 1863
    # saida
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 1863 -j ACCEPT
    # Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 1863 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ######################################
    echo 'Permitindo Rede Local Acessar Real'
    # Permite a Rede Local Acessar a Real Seguros ( 3265 )
    # Saida
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 3265 -j ACCEPT
    # Retorno
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 3265 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ######################################
    echo 'Permitindo a Rede Local Accessa Maritima'
    # Permite a Rede Local Acessar a Maritima Seguros ( 433 )
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 433 -j ACCEPT
    # Retorno
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 433 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    ######################################
    #echo 'Permite o Acesso ao LimeWare'
    # Permite o adriano acessar o LimeWare
    #iptables -t nat -A PREROUTING -p UDP -d $REDE1 --dport 6346 -j DNAT --to-destination $ADRIANO


    echo 'Permitindo Rede Local Acessar Itau'
    # Permite a Rede Local acessar a Itau Seguros (1723)
    # Saida
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 443 -j ACCEPT
    # Resposta
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 443 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    #####################################
    echo 'Permitindo Rede Local Acessar Porto Seguro'
    #Permite a Rede Local acessar a Porto Seguro
    # Saida
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 220 -j ACCEPT
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 0/0 -o eth1 --dport 6000 -j ACCEPT
    # Retorno
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 220 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    iptables -A FORWARD -p tcp -s 0/0 -i eth1 --sport 6000 -d $REDE1 -o eth0 --dport 1024: -j ACCEPT
    #####################################
    echo 'Permite a Rede Local Acessar AGF'
    # Permite a Rede Local Acessar a Agf Seguros
    # Saida
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 200.230.35.245 --dport 8080 -j ACCEPT
    # Retorno
    iptables -A FORWARD -p tcp -s 200.230.35.245 -i eth1 --sport 8080 -d $REDE1 -o eth1 --dport 1024: -j ACCEPT
    ####################################
    echo 'Permite a Rede Local Accesar AnnNet'
    # Permite a Rede Local Accesar a AnNet
    # Saida
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 200.230.42.69 --dport 8080 -j ACCEPT
    # Retorno
    iptables -A FORWARD -p tcp -s 200.230.42.69 -i eth1 --sport 8080 -d $REDE1 -o eth1 --dport 1024: -j ACCEPT
    ####################################
    echo 'Permite a Rede Local Acessa a Liberty'
    # Permite a Rede Local Acessar a Liberty
    # Saida
    iptables -A FORWARD -p tcp -s $REDE1 -i eth0 --sport 1024: -d 200.160.248.196 --dport 8080 -j ACCEPT
    # Retorno
    iptables -A FORWARD -p tcp -s 200.160.248.196 -i eth1 --sport 8080 -d $REDE1 -o eth1 --dport 1024: -j ACCEPT
    ###################################




    # iptables -A OUTPUT -d $REDE1 -o eth1 -p tcp --sport 1723 -j ACCEPT
    # iptables -A FORWARD -s $REDE1 -p tcp --dport 1723 -j ACCEPT
    # iptables -A INPUT -i eth1 -p tcp --dport 1723 -j ACCEPT
    echo 'Permitindo Rede Local Acessar VPN'
    #VPN
    # Permite o acceso da Rede Local Usando VPN ( 47 ) ( 1723 )
    iptables -A INPUT -p TCP --dport 1723 -j ACCEPT
    iptables -A OUTPUT -p TCP --dport 1723 -j ACCEPT
    iptables -A FORWARD -p TCP -m multiport --dport 1723,1701 -j ACCEPT
    iptables -A FORWARD -p UDP -m multiport --dport 1723,1701 -j ACCEPT
    iptables -A INPUT -p 47 -j ACCEPT
    iptables -A OUTPUT -p 47 -j ACCEPT
    iptables -A FORWARD -p 47 -j ACCEPT
    #################################################

    echo 'Permitindo Rede Local Acessar SSH'
    # Permite a Rede Local conectar ao servidor usando SSH
    iptables -A OUTPUT -d $REDE1 -o eth0 -p tcp --sport 22 -j ACCEPT
    iptables -A FORWARD -s $REDE1 -p tcp --dport 22 -j ACCEPT
    iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
    ######################################

    # Permite a Rede Local Acessar a Porta MySQL
    echo 'Permite a Rede Local Acessar a Porta MySQL'
    iptables -A OUTPUT -d $REDE1 -o eth0 -p tcp --sport 3306 -j ACCEPT
    iptables -A FORWARD -s $REDE1 -p tcp --dport 3306 -j ACCEPT
    iptables -A INPUT -i eth0 -p tcp --dport 3306 -j ACCEPT
    ######################################


    ############# PROXY DENTRO DO FIREWALL
    echo 'Ligando o Proxy Transparente'
    ########## Redireciona os pacotes para porta 80 para a 3128

    iptables -t nat -A PREROUTING -p tcp -s $REDE1 -i eth0 -d 0/0 --dport 80 -j REDIRECT --to-port 3128

    # iptables -t nat -A PREROUTING -p tcp -s $REDE1 -i eth0 -d 0/0 --dport 443 -j REDIRECT --to-port 3128
    ####################################

    ######### Permite a entrada de pacotes para a porta 3128
    iptables -A INPUT -s $REDE1 -i eth0 -p tcp --dport 3128 -j ACCEPT
    ##########################

    ######## Permite a Rede Local enviar pacotes para a porta 80 na Web
    #### Obs: devido a Politica FORWARD ser "DROP", eh necessario
    #### tal regra para que inicialmente o pacote chegue ao servidor
    #### para que ele possa fazer o redirecionamento para o proxy.
    #### Note que esta regra deve vir depois da regra do "PREROUTING"
    #### onde definimos o redirecionamento

    iptables -A FORWARD -s $REDE1 -p tcp --dport 80 -j ACCEPT
    # iptables -A FORWARD -s $REDE1 -p tcp --dport 443 -j ACCEPT
    ######################

    ############ Libera o PROXY, que está dentro do firewall pesquisar na web
    iptables -A OUTPUT -p tcp -o eth1 -d -0/0 --dport 80 -j ACCEPT
    iptables -A INPUT -p tcp -i eth1 -s -0/0 --sport 80 -j ACCEPT

    # iptables -A OUTPUT -p tcp -o eth1 -d -0/0 --dport 443 -j ACCEPT
    # iptables -A INPUT -p tcp -i eth1 -s -0/0 --sport 443 -j ACCEPT
    ##########################


    ############ Libera o PROXY, que está dentro do firewall pesquisar DNS
    iptables -A OUTPUT -p udp -o eth1 -d -0/0 --dport 53 -j ACCEPT
    iptables -A INPUT -p udp -i eth1 -s -0/0 --sport 53 -j ACCEPT
    ####################


    ############ Libera o retorno do pacotes do PROXY para a rede local
    iptables -A OUTPUT -d $REDE1 -o eth0 -p tcp --sport 3128 -j ACCEPT
    ##########################

    # Libera o trafico da Rede1 para rede2
    echo 'Libera o trafego da Rede1 para Rede2 ( Gateway )'
    iptables -A INPUT -s $REDE1 -d $REDE2 -j ACCEPT
    iptables -A FORWARD -s $REDE1 -d $REDE2 -j ACCEPT
    iptables -A OUTPUT -s $REDE1 -d $REDE2 -j ACCEPT
    ##########################

    ########### Libera o trafico interno da loopback com ela mesma
    echo 'Libera o Loopback'
    iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
    iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
    ############################


    echo -e '\e[;32;5m Firewall Ativo! \e[m'



  3. Olha q é isso q vc quer: https://under-linux.org/modules.php?...ticle&sid=5001

    Abraço

  4. aff!! :roll:






Tópicos Similares

  1. Squid Transparente + Iptables = msn não funciona !!
    Por fotg no fórum Servidores de Rede
    Respostas: 5
    Último Post: 30-01-2005, 05:07
  2. Squid transparente com ACL's
    Por amarques no fórum Servidores de Rede
    Respostas: 4
    Último Post: 24-10-2004, 13:07
  3. Problema Squid Transparente
    Por lgoncalves no fórum Servidores de Rede
    Respostas: 10
    Último Post: 28-08-2004, 10:55
  4. Squid Transparente e Limitação de Acesso à Usuários de Domín
    Por Hawthorn no fórum Servidores de Rede
    Respostas: 6
    Último Post: 17-06-2003, 23:45
  5. Squid Transparente com autenticação
    Por escambau no fórum Servidores de Rede
    Respostas: 0
    Último Post: 10-01-2003, 14:19

Visite: BR-Linux ·  VivaOLinux ·  Dicas-L