Página 1 de 2 12 ÚltimoÚltimo
+ Responder ao Tópico



  1. #1
    redoctober
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Seguinte: Detalhes da minha rede;

    ---INTERNET----
    |
    ROTEADOR 200.222.54.62
    |
    SERVIDOR > rede 1 = 200.222.54.2 (Válida)
    > rede 2 = 10.10.1.10 (Invalida)

    ==========================================
    Problema
    -----------

    Tenho 23 usuário na rede inválida que precisam navegar com IPs válidos
    como farei para que os usuário que estão na rede invalida saiam para internet com IP válido, todos tem que ter IP diferente.

    Estou a beira de um ataque de nervos...

    Valeu

  2. #2

    Padrão Problema que nao consegui resolver - NAT

    ips diferentes?????? vc soh vai conseguir fazer isso se vc tb tiver varios ips validos..... se naum cada um vai sair com o mesmo ip



  3. #3
    redoctober
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Eu tenho 64 IPs válidos prontos para usar, só não sei como fazer

    []´s

  4. #4
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Simon sabe o que fala...
    Simon loko é verdade...
    Simon pergunta diz:
    "Se vc tiver gateway linux pode utilizar o script abaixo para seu rc.firewall"
    Obs: Este script usa tecnica de mascaramento de ip´s, portanto mtos travas de seguranças devem ser inseridas ou a invasão pode ocorrer sussegadamente.
    Simon usar técnica complicada de cut em grud..."

    #!/bin/sh
    #
    # rc.firewall-2.4
    FWVER=0.63
    #
    # Initial SIMPLE IP Masquerade test for 2.4.x kernels
    # using IPTABLES.
    #
    # Once IP Masquerading has been tested, with this simple
    # ruleset, it is highly recommended to use a stronger
    # IPTABLES ruleset either given later in this HOWTO or
    # from another reputable resource.
    #
    #
    #
    # Log:
    # 0.63 - Added support for the IRC IPTABLES module
    # 0.62 - Fixed a typo on the MASQ enable line that used eth0
    # instead of $EXTIF
    # 0.61 - Changed the firewall to use variables for the internal
    # and external interfaces.
    # 0.60 - 0.50 had a mistake where the ruleset had a rule to DROP
    # all forwarded packets but it didn´t have a rule to ACCEPT
    # any packets to be forwarded either
    # - Load the ip_nat_ftp and ip_conntrack_ftp modules by default
    # 0.50 - Initial draft
    #

    echo -e "\n\nLoading simple rc.firewall version $FWVER..\n"


    # The location of the ´iptables´ program
    #
    # If your Linux distribution came with a copy of iptables, most
    # likely it is located in /sbin. If you manually compiled
    # iptables, the default location is in /usr/local/sbin
    #
    # ** Please use the "whereis iptables" command to figure out
    # ** where your copy is and change the path below to reflect
    # ** your setup
    #
    IPTABLES=/sbin/iptables


    #Setting the EXTERNAL and INTERNAL interfaces for the network
    #
    # Each IP Masquerade network needs to have at least one
    # external and one internal network. The external network
    # is where the natting will occur and the internal network
    # should preferably be addressed with a RFC1918 private address
    # scheme.
    #
    # For this example, "eth0" is external and "eth1" is internal"
    #
    # NOTE: If this doesnt EXACTLY fit your configuration, you must
    # change the EXTIF or INTIF variables above. For example:
    #
    # EXTIF="ppp0"
    #
    # if you are a modem user.
    #
    EXTIF="eth0"
    INTIF="eth1"
    echo " External Interface: $EXTIF"
    echo " Internal Interface: $INTIF"


    #======================================================================
    #== No editing beyond this line is required for initial MASQ testing ==


    echo -en " loading modules: "

    # Need to verify that all modules have all required dependencies
    #
    echo " - Verifying that all kernel modules are ok"
    /sbin/depmod -a

    # With the new IPTABLES code, the core MASQ functionality is now either
    # modular or compiled into the kernel. This HOWTO shows ALL IPTABLES
    # options as MODULES. If your kernel is compiled correctly, there is
    # NO need to load the kernel modules manually.
    #
    # NOTE: The following items are listed ONLY for informational reasons.
    # There is no reason to manual load these modules unless your
    # kernel is either mis-configured or you intentionally disabled
    # the kernel module autoloader.
    #

    # Upon the commands of starting up IP Masq on the server, the
    # following kernel modules will be automatically loaded:
    #
    # NOTE: Only load the IP MASQ modules you need. All current IP MASQ
    # modules are shown below but are commented out from loading.
    # ===============================================================
    #Load the main body of the IPTABLES module - "iptable"
    # - Loaded automatically when the "iptables" command is invoked
    #
    # - Loaded manually to clean up kernel auto-loading timing issues
    #
    echo -en "ip_tables, "
    /sbin/insmod ip_tables


    #Load the IPTABLES filtering module - "iptable_filter"
    # - Loaded automatically when filter policies are activated


    #Load the stateful connection tracking framework - "ip_conntrack"
    #
    # The conntrack module in itself does nothing without other specific
    # conntrack modules being loaded afterwards such as the "ip_conntrack_ftp"
    # module
    #
    # - This module is loaded automatically when MASQ functionality is
    # enabled
    #
    # - Loaded manually to clean up kernel auto-loading timing issues
    #
    echo -en "ip_conntrack, "
    /sbin/insmod ip_conntrack


    #Load the FTP tracking mechanism for full FTP tracking
    #
    # Enabled by default -- insert a "#" on the next line to deactivate
    #
    echo -en "ip_conntrack_ftp, "
    /sbin/insmod ip_conntrack_ftp


    #Load the IRC tracking mechanism for full IRC tracking
    #
    # Enabled by default -- insert a "#" on the next line to deactivate
    #
    echo -en "ip_conntrack_irc, "
    /sbin/insmod ip_conntrack_irc


    #Load the general IPTABLES NAT code - "iptable_nat"
    # - Loaded automatically when MASQ functionality is turned on
    #
    # - Loaded manually to clean up kernel auto-loading timing issues
    #
    echo -en "iptable_nat, "
    /sbin/insmod iptable_nat



    #Loads the FTP NAT functionality into the core IPTABLES code
    # Required to support non-PASV FTP.
    #
    # Enabled by default -- insert a "#" on the next line to deactivate
    #
    echo -en "ip_nat_ftp, "
    /sbin/insmod ip_nat_ftp


    # Just to be complete, here is a list of the remaining kernel modules
    # and their function. Please note that several modules should be only
    # loaded by the correct master kernel module for proper operation.
    # --------------------------------------------------------------------
    #
    # ipt_mark - this target marks a given packet for future action.
    # This automatically loads the ipt_MARK module
    #
    # ipt_tcpmss - this target allows to manipulate the TCP MSS
    # option for braindead remote firewalls.
    # This automatically loads the ipt_TCPMSS module
    #
    # ipt_limit - this target allows for packets to be limited to
    # to many hits per sec/min/hr
    #
    # ipt_multiport - this match allows for targets within a range
    # of port numbers vs. listing each port individually
    #
    # ipt_state - this match allows to catch packets with various
    # IP and TCP flags set/unset
    #
    # ipt_unclean - this match allows to catch packets that have invalid
    # IP/TCP flags set
    #
    # iptable_filter - this module allows for packets to be DROPped,
    # REJECTed, or LOGged. This module automatically
    # loads the following modules:
    #
    # ipt_LOG - this target allows for packets to be
    # logged
    #
    # ipt_REJECT - this target DROPs the packet and returns
    # a configurable ICMP packet back to the
    # sender.
    #
    # iptable_mangle - this target allows for packets to be manipulated
    # for things like the TCPMSS option, etc.

    echo ". Done loading modules."



    #CRITICAL: Enable IP forwarding since it is disabled by default since
    #
    # Redhat Users: you may try changing the options in
    # /etc/sysconfig/network from:
    #
    # FORWARD_IPV4=false
    # to
    # FORWARD_IPV4=true
    #
    echo " enabling forwarding.."
    echo "1" > /proc/sys/net/ipv4/ip_forward
    # Dynamic IP users:
    #
    # If you get your IP address dynamically from SLIP, PPP, or DHCP,
    # enable this following option. This enables dynamic-address hacking
    # which makes the life with Diald and similar programs much easier.
    #
    echo " enabling DynamicAddr.."
    echo "1" > /proc/sys/net/ipv4/ip_dynaddr


    # Enable simple IP forwarding and Masquerading
    #
    # NOTE: In IPTABLES speak, IP Masquerading is a form of SourceNAT or SNAT.
    #
    # NOTE #2: The following is an example for an internal LAN address in the
    # 192.168.0.x network with a 255.255.255.0 or a "24" bit subnet mask
    # connecting to the Internet on external interface "eth0". This
    # example will MASQ internal traffic out to the Internet but not
    # allow non-initiated traffic into your internal network.
    #
    #
    # ** Please change the above network numbers, subnet mask, and your
    # *** Internet connection interface name to match your setup
    #


    #Clearing any previous configuration
    #
    # Unless specified, the defaults for INPUT and OUTPUT is ACCEPT
    # The default for FORWARD is DROP
    #
    echo " clearing any existing rules and setting default policy.."
    # By Marcos
    $IPTABLES -P INPUT ACCEPT
    $IPTABLES -F INPUT
    $IPTABLES -P OUTPUT ACCEPT
    $IPTABLES -F OUTPUT
    $IPTABLES -P FORWARD DROP
    $IPTABLES -F FORWARD
    $IPTABLES -t nat -F

    echo " FWD: Allow all connections OUT and only existing and related ones IN"
    $IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
    $IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
    $IPTABLES -A FORWARD -j LOG

    echo " Enabling SNAT (MASQUERADE) functionality on $EXTIF"
    $IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.2/32 -j MASQUERADE
    $IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.3/32 -j MASQUERADE

    #$IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.4/32 -j MASQUERADE
    #$IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.5/32 -j MASQUERADE
    #$IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.6/32 -j MASQUERADE

    #$IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.7/32 -j MASQUERADE
    #$IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.8/32 -j MASQUERADE
    #$IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 192.168.0.9/32 -j MASQUERADE



    echo -e "\nDone.\n"
    # End by Simon

    ##################################################
    ACABOU AGORA COPIE E COLE.

    Simon diz:
    "Se ajudar isso... verificar IP´s e eth0 e eth1."



  5. #5
    redoctober
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Dúvidas...

    Como cada cliente terá o IP válido atriuido a ele??? Tipo.... Como o usuário do ip 10.10.1.21 terá o ip válido 200.243.168.30?

    []´s

  6. #6
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Simon pergunta pra Sábio:
    "Vc tem um gateway fazendo o serviço de roteamento?"
    Vide DIAGRAMA:

    [eth0] <------> roteador/rc.firewall <------> [eth1]
    DHCP ip-fixo - para todas maquinas
    fornecido cada maquina da rede deve ser
    pelo seu configurada com ip fixos.
    servidor de internet 192.168.0.X vc pode alterar p/
    10.10.1.X cada maquina da rede
    interna deve ser acrescentada
    no final.
    #!TODAS AS MAQUINAS INTERNAS (ABAIXO GATEWAY)
    #DEVEM TER IP FIXOS ATRIBUÍDOS.
    #CADA UMA DEFINIDA INDIVIDUALMENTE, NO SEU CASO O FINAL
    # DO ARQUIVO RC.FIREWALL SERIA:

    echo " Enabling SNAT (MASQUERADE) functionality on $EXTIF"
    $IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 10.10.1.2/32 -j MASQUERADE
    $IPTABLES -t nat -A POSTROUTING -o $EXTIF -s 10.10.1.3/32 -j MASQUERADE

    # E ASSIM SEGUE PRA CADA UMA MAQUINA DA REDE




  7. #7
    redoctober
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    OK...
    Qual será o IP que o usuário 10.10.1.3/32 sairá para a Internet?


  8. #8

    Padrão Problema que nao consegui resolver - NAT

    para fazer com q cada ip interno seja alterado vc vai precisar fazer isso:

    iptables -t nat -A POSTROUTING -s IP_INTERNO1 -j SNAT --to IP_VALIDO1
    iptables -t nat -A POSTROUTING -s IP_INTERNO2 -j SNAT --to IP_VALIDO2
    .
    .
    .
    etc....



  9. #9
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    veja como ficou as minhas regras de IPTABLES:
    -----------


    Checking for Firewall: Chain INPUT (policy ACCEPT)
    target prot opt source destination

    Chain FORWARD (policy DROP)
    target prot opt source destination
    ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
    ACCEPT all -- anywhere anywhere
    LOG all -- anywhere anywhere LOG level warning

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination
    Chain PREROUTING (policy ACCEPT)
    target prot opt source destination

    Chain POSTROUTING (policy ACCEPT)
    target prot opt source destination
    SNAT all -- 10.10.10.2 anywhere to:200.243.54.16

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination

    -------------

    Observacoes:
    A maquina que esta com o firewall esta com a seguintes configuracoes
    ================================================================
    ---- Placa de Rede externa eth0 = 200.243.54.11
    ---- Placa de Rede interna eth1 = 10.10.10.1
    ---- Gateway = 200.243.54.62

    A maquina que esta na rede 10.0.0.0
    =================================
    ---- Placa de Rede eth0 = 10.10.10.2
    ---- Gateway = 10.10.10.1


    E mesmo assim a maquina 10.10.10.2 nao esta indo pra internet com o ip 200.243.54.16

    ... Qual sera o problema?

  10. #10

    Padrão Problema que nao consegui resolver - NAT

    o problema deve ser esse:
    Chain FORWARD (policy DROP)

    coloca ai iptables -P FORWARD ACCEPT



  11. #11
    redoctober
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Coloquei a CHAIN e ainda nada!

  12. #12
    redoctober
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Bom pessoal com do jeito antigo nao deu estou tentando assim:


    (((((--Servidor - INTERNET--)))))
    =----Placa de rede ETH0 = 200.243.54.11
    =----Placa de rede ETH1 = 200.243.168.20
    =---- Gateway = 200.243.54.62 -- Roteador PR4000 onde estao as classe de IPs 168 e 54 declaradas

    ((--Maquina Cliente--))
    =---- Placa de rede ETH0 = 200.243.168.21
    =---- Gateway = 200.243.168.20



    ==== ESSA E A MINHA TABELA DE ROTEAMENTO ====

    Tabela de Roteamento IP do Kernel
    Destino---------Roteador---------MáscaraGen.-----Opções---Métrica---Ref----Uso---Iface
    200.243.168.0 * 255.255.255.192 U 0 0 0 eth1
    200.243.54.0 * 255.255.255.192 U 0 0 0 eth0
    127.0.0.0 * 255.0.0.0 U 0 0 0 lo
    default 200.243.54.62 0.0.0.0 UG 0 0 0 eth0



    Nesse novo esquema eu nao estou utilizando nenhuma regra de firewall! Mais mesmo assim o computador que esta com o IP = 200.243.168.21 nao consegue ir para a Internet.

    Deve utilizar alguma regra de firewall??? Penso eu que so a tabela de ROTEAMENTO resolveria...

    Me ajudem!?!?!?!


    <IMG SRC="images/forum/icons/icon_eek.gif">



  13. #13
    Mr_Mind
    Visitante

    Padrão Problema que nao consegui resolver - NAT


  14. #14

    Padrão Problema que nao consegui resolver - NAT

    falae sumido....
    infelizmente num ta sendo tao simples assim...
    to falando com o colega pelo icq...



  15. #15

    Padrão Problema que nao consegui resolver - NAT

    Kra vc tb pode configurar um a brigde transparente para pode passar estes ips para sua rede interna.

  16. #16
    Leyzem
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    faça isso
    esterna = eth0 - 200.222.54.2
    interna = eth1 - 10.10.1.10

    iptables -P FORWARD -j DROP
    iptables -A FORWARD -s 10.10.1.0/24 -i eth1 -o eth0 -j ACCEPT
    iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

    iptables -t nat -A POSTROUTING -s 10.10.1.0/24 -o eth0 -j SNAT --to 200.222.54.2

    isto é o suficiente para o rotiamento...

    detalhe - o gateway do seu linux é o roteador

    e não se esqueça de configurar as maquina windows , configuração de rede, gateway coloque o ip do server linux - 10.10.1.10 e na parte de DNS coloque o DNS do provedor

    espero ter ajudado



  17. #17

    Padrão Problema que nao consegui resolver - NAT

    cara jah falei q num eh tao simples assim,
    ele tem um roteador na frente do linux e depois o linux faz o rotemento interno.....
    e outra TUDO EH IP VALIDO

  18. #18
    Leyzem
    Visitante

    Padrão Problema que nao consegui resolver - NAT


    On 2003-01-09 16:04, Leyzem wrote:
    faça isso
    esterna = eth0 - 200.222.54.2
    interna = eth1 - 10.10.1.10

    iptables -P FORWARD -j DROP
    iptables -A FORWARD -s 10.10.1.0/24 -i eth1 -o eth0 -j ACCEPT
    iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

    iptables -t nat -A POSTROUTING -s 10.10.1.0/24 -o eth0 -j SNAT --to 200.222.54.2

    isto é o suficiente para o rotiamento...

    detalhe - o gateway do seu linux é o roteador

    e não se esqueça de configurar as maquina windows , configuração de rede, gateway coloque o ip do server linux - 10.10.1.10 e na parte de DNS coloque o DNS do provedor

    espero ter ajudado


    há e não se esqueça de colocar digitar
    echo "1" > /proc/sys/net/ipv4/ip_forward
    <IMG SRC="images/forum/icons/icon_biggrin.gif"> <IMG SRC="images/forum/icons/icon_wink.gif">



  19. #19
    Leyzem
    Visitante

    Padrão Problema que nao consegui resolver - NAT

    Tente isso
    esterna = eth0 - 200.222.54.2
    interna = eth1 - 10.10.1.10

    iptables -P FORWARD -j DROP
    iptables -A FORWARD -s 10.10.1.0/24 -i eth1 -o eth0 -j ACCEPT
    iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

    iptables -t nat -A POSTROUTING -s 10.10.1.0/24 -o eth0 -j SNAT --to 200.222.54.2

    isto é o suficiente para o rotiamento...

    detalhe - o gateway do seu linux é o roteador

    e não se esqueça de configurar as maquina windows , configuração de rede, gateway coloque o ip do server linux - 10.10.1.10 e na parte de DNS coloque o DNS do provedor

    espero ter ajudado


    há e não se esqueça de colocar digitar
    echo "1" > /proc/sys/net/ipv4/ip_forward
    <IMG SRC="images/forum/icons/icon_biggrin.gif"> <IMG SRC="images/forum/icons/icon_wink.gif">

  20. #20

    Padrão Problema que nao consegui resolver - NAT

    soh vou falar uma coisa.........
    leia as msgs anteriores antes de falar..