+ Responder ao Tópico



  1. #1

    Padrão Iptables, acessar servidor interno de fora da rede

    Tenho a seguinte estrutura:
    1 Firewall com 2 pl. de rede rodando Centos 5

    Tenho uma aplicação web rodando em jboss na porta 8080, em um servidor na intranet e gostaria de acessa-lo externamente eu tentei a seguinte regra mas não funcionou:

    iptables -A INPUT -i eth1 -s 0/0 -d 192.168.0.1 (ip da placa de rede que chega a internet) -p tcp --dport 8080 -m state --state NEW -j ACCEPT
    iptables -A FORWARD -i eth1 -s 0/0 -d 192.168.0.1 (ip da placa de rede que chega internet) -p tcp --dport 8080 -m state --state NEW -j ACCEPT
    iptables -t nat -A PREROUTING -i eth1 -s 0/0 -p tcp --dport 8080 -j DNAT --to 192.168.200.10:8080

    Eu já fiz essa regra para acessar um SSH de um servidor interno e funcionou, porem agora não esta funcionando alguem sabe porque?

  2. #2

    Padrão Re: Iptables, acessar servidor interno de fora da rede

    Pode copiar a saída dos comandos:
    iptables -L
    iptables -L -t nat

  3. #3

    Padrão Re: Iptables, acessar servidor interno de fora da rede

    iptables -t nat -A PREROUTING -s $ip_externo -p tcp -m tcp --dport 8080 -j DNAT --to $ip_interno
    iptables -t nat -A POSTROUTING -s $ip_interno -p tcp -m tcp --dport 8080 -j SNAT --to $ip_externo

    pra redirecionamento, só funciona quando há SNAT tambem...

    boa sorte!

  4. #4

    Padrão Re: Iptables, acessar servidor interno de fora da rede

    iptables -L (nao cabe tudo entao coloquei so a primeira parte)
    Código :
    Chain INPUT (policy DROP)
    target     prot opt source               destination         
    ACCEPT     all  --  anywhere             anywhere            
    ACCEPT     icmp --  anywhere             anywhere            
    ACCEPT     udp  --  anywhere             anywhere            udp dpt:domain 
    ACCEPT     udp  --  anywhere             anywhere            udp spt:domain 
    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ssh 
    ACCEPT     udp  --  anywhere             anywhere            udp spt:ntp 
    ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:http 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:https 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:hosts2-ns 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:surf 
    ACCEPT     tcp  --  anywhere             192.168.0.1         tcp dpt:ms-wbt-server state NEW 
    ACCEPT     tcp  --  anywhere             192.168.0.1         tcp dpt:webcache state NEW 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:webcache 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:websm 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ftp 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ftp-data 
    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:squid 
    ACCEPT     all  --  192.168.200.1        anywhere            
    ACCEPT     all  --  192.168.200.3        anywhere            
    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ms-wbt-server 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ms-wbt-server 
    ACCEPT     udp  --  anywhere             anywhere            udp dpts:netbios-ns:netbios-ssn 
    ACCEPT     tcp  --  anywhere             anywhere            tcp dpts:netbios-ns:netbios-ssn 
    ACCEPT     udp  --  anywhere             anywhere            udp spts:netbios-ns:netbios-ssn 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spts:netbios-ns:netbios-ssn 
    ACCEPT     udp  --  anywhere             anywhere            udp spt:microsoft-ds 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:microsoft-ds 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:msnp 
    ACCEPT     tcp  --  anywhere             anywhere            tcp spt:afs3-callback 
               all  --  anywhere             anywhere

    iptables -L -t nat
    Código :
    Chain PREROUTING (policy ACCEPT)
    target     prot opt source               destination         
    DNAT       tcp  --  anywhere             anywhere            tcp dpt:ms-wbt-server to:192.168.200.15 
    DNAT       tcp  --  anywhere             anywhere            tcp dpt:webcache to:192.168.200.4:8080 
    DNAT       tcp  --  anywhere             192.168.0.1         tcp dpt:1024 to:192.168.200.1 
    DNAT       tcp  --  anywhere             192.168.0.1         tcp dpt:ftp to:192.168.200.1 
    DNAT       tcp  --  anywhere             192.168.0.1         tcp dpt:blackjack to:192.168.200.1 
     
    Chain POSTROUTING (policy ACCEPT)
    target     prot opt source               destination         
    SNAT       all  --  192.168.200.0/24     anywhere            to:192.168.0.1 
     
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination

    Lincoin tente com sua regra porem me retorna o mesmo erro:

    Código :
    Na tentativa de recuperar a URL: http://XXX.XXX.XX.XXX:8080/
     
    O seguinte erro foi encontrado:
     
    Falha na conexão
    O sistema retornou:
     
        (111) Connection refused

  5. #5

    Padrão Re: Iptables, acessar servidor interno de fora da rede

    desabilita o firewall

    refaça as regras q eu te passei e ative o ip_forward

    Código :
    echo "1">/proc/sys/net/ipv4/ip_forward

  6. #6

    Padrão Re: Iptables, acessar servidor interno de fora da rede

    ip_forward já esta ativado.
    Dentro do /proc/sys/net/ipv4/ip_forward já tem o 1