+ Responder ao Tópico



  1. #1

    Padrão Não consigo redirecionar para o VNC ???

    Olá!

    Já procurei por todo o forum e fiz várias tentativas, mas sem sucesso...

    Tenho um Servidor com o Kurumin 5.0 rodando Squid, Samba e compartilhando a Internet, está fudo funcionando, só não consigo configurar o redirecionamento para as máquinas WinXP da rede para poder acessá-las de fora da empresa.

    Segue abaixo meu arquivo de configuração para saber o que posso estar fazendo errado.

    Valeu!

    #!/bin/bash

    # Script de configuração do iptables gerado pelo configurador do Kurumin
    # Este script pode ser usado em outras distribuições Linux que utilizam o Kernel 2.4 em diante
    # Por Carlos E. Morimoto

    firewall_start(){

    # Abre para uma faixa de endereços da rede local
    iptables -A INPUT -p tcp -s 192.168.0.0/255.255.255.0 -j ACCEPT
    iptables -A INPUT -p udp -s 192.168.0.0/255.255.255.0 -j ACCEPT
    iptables -A INPUT -p tcp -s 0.0.0.0/0 -j ACCEPT
    iptables -A INPUT -p udp -s 0.0.0.0/0 -j ACCEPT

    # Abre uma porta (inclusive para a Internet)
    iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT

    # Abre uma porta (inclusive para a Internet)
    iptables -A INPUT -p tcp --destination-port 6881 -j ACCEPT

    # Abre uma porta (inclusive para a Internet)
    iptables -A INPUT -p tcp --destination-port 5800 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5801 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5802 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5803 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5804 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5805 -j ACCEPT

    iptables -A INPUT -p tcp --destination-port 5806 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5807 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5808 -j ACCEPT

    # Abre uma porta (inclusive para a Internet)
    iptables -A INPUT -p tcp --destination-port 5900 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5901 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5902 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5903 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5904 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5905 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5906 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5907 -j ACCEPT
    iptables -A INPUT -p tcp --destination-port 5908 -j ACCEPT

    # Ignora pings
    # echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

    # Protege contra synflood
    echo "1" > /proc/sys/net/ipv4/tcp_syncookies

    # Proteção contra ICMP Broadcasting
    echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

    # Bloqueia traceroute
    iptables -A INPUT -p udp --dport 33435:33525 -j DROP


    # Proteções diversas contra portscanners, ping of death, ataques DoS, etc.
    iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
    iptables -A FORWARD -p tcp -m limit --limit 1/s -j ACCEPT
    iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
    iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
    iptables -A FORWARD --protocol tcp --tcp-flags ALL SYN,ACK -j DROP
    iptables -A FORWARD -m unclean -j DROP
    iptables -A INPUT -m state --state INVALID -j DROP
    iptables -N VALID_CHECK
    iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
    iptables -A VALID_CHECK -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
    iptables -A VALID_CHECK -p tcp --tcp-flags ALL ALL -j DROP
    iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN -j DROP
    iptables -A VALID_CHECK -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
    iptables -A VALID_CHECK -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
    iptables -A VALID_CHECK -p tcp --tcp-flags ALL NONE -j DROP


    # Abre para a interface de loopback.
    # Esta regra é essencial para o KDE e outros programas gráficos funcionarem adequadamente.
    iptables -A INPUT -p tcp --syn -s 127.0.0.1/255.0.0.0 -j ACCEPT
    iptables -A INPUT -i lo -j ACCEPT


    # Fecha as portas udp de 1 a 1024, abre para o localhost
    iptables -A INPUT -p udp -s 127.0.0.1/255.0.0.0 -j ACCEPT
    iptables -A INPUT -p udp --dport 1:1024 -j DROP
    iptables -A INPUT -p udp --dport 59229 -j DROP

    # Firewall liberando portas para o VNC

    #coloque aqui seu IP p. ex. "200.246.13.45"
    IP_ORIGEM="0.0.0.0/0"
    IP_DESTINO="IP do Speedy"

    # Abre portas para o VNC
    iptables -t filter -A INPUT -p tcp --dport 5900 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5800 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5902 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5802 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5903 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5803 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5904 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5804 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5905 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5805 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5906 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5806 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5907 -j ACCEPT -i eth0
    iptables -t filter -A INPUT -p tcp --dport 5807 -j ACCEPT -i eth0

    # Redirecionamento das portas do VNC
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5802 -j DNAT --to-destination 192.168.0.2:5800
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5902 -j DNAT --to-destination 192.168.0.2:5900
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5803 -j DNAT --to-destination 192.168.0.3:5800
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5903 -j DNAT --to-destination 192.168.0.3:5900
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5804 -j DNAT --to-destination 192.168.0.4:5800
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5904 -j DNAT --to-destination 192.168.0.4:5900
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5805 -j DNAT --to-destination 192.168.0.5:5800
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5905 -j DNAT --to-destination 192.168.0.5:5900
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5806 -j DNAT --to-destination 192.168.0.6:5800
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5906 -j DNAT --to-destination 192.168.0.6:5900
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5807 -j DNAT --to-destination 192.168.0.7:5800
    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5907 -j DNAT --to-destination 192.168.0.7:5900

    # permite pacotes da Internet para a maquina com o VNC Server
    iptables -A FORWARD -p tcp -s $IP_ORIGEM -d 192.168.0.1 --dport 5800 -j ACCEPT
    iptables -A FORWARD -p tcp -s $IP_ORIGEM -d 192.168.0.2 --dport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -s $IP_ORIGEM -d 192.168.0.3 --dport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -s $IP_ORIGEM -d 192.168.0.4 --dport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -s $IP_ORIGEM -d 192.168.0.5 --dport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -s $IP_ORIGEM -d 192.168.0.6 --dport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -s $IP_ORIGEM -d 192.168.0.7 --dport 5900 -j ACCEPT

    # permite pacotes de reposta da maquina com o VNC Server
    iptables -A FORWARD -p tcp -d $IP_ORIGEM -s 192.168.0.1 --sport 5800 -j ACCEPT
    iptables -A FORWARD -p tcp -d $IP_ORIGEM -s 192.168.0.2 --sport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -d $IP_ORIGEM -s 192.168.0.3 --sport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -d $IP_ORIGEM -s 192.168.0.4 --sport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -d $IP_ORIGEM -s 192.168.0.5 --sport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -d $IP_ORIGEM -s 192.168.0.6 --sport 5900 -j ACCEPT
    iptables -A FORWARD -p tcp -d $IP_ORIGEM -s 192.168.0.7 --sport 5900 -j ACCEPT


    # Esta regra é o coração do firewall do Kurumin,
    # ela bloqueia qualquer conexão que não tenha sido permitida acima, justamente por isso ela é a última da cadeia.
    iptables -A INPUT -p tcp --syn -j DROP

    /etc/skel-fix/firewall-msg

    }
    firewall_stop(){
    iptables -F
    iptables -X
    iptables -P INPUT ACCEPT
    iptables -P FORWARD ACCEPT
    iptables -P OUTPUT ACCEPT
    }

    case "$1" in
    "start")
    firewall_start
    ;;
    "stop")
    firewall_stop
    echo "O kurumin-firewall está sendo desativado"
    sleep 2
    echo "ok."
    ;;
    "restart")
    echo "O kurumin-firewall está sendo desativado"
    sleep 1
    echo "ok."
    firewall_stop; firewall_start
    ;;
    *)
    iptables -L -n
    esac

  2. #2
    ROGÉRIO GONZAGA
    Visitante

    Padrão TENTE ALTERAR O NRO. DA PRIMEIRA PORTA

    A sua regra está quase certa, mas compare as duas abaixo:

    Sua regra:

    iptables -t nat -A PREROUTING -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5802 -j DNAT --to-destination 192.168.0.2:5800

    Minha regra:

    iptables -A PREROUTING -t nat -p tcp -s $IP_ORIGEM -d $IP_DESTINO --dport 5900 -j NAT -to $IP_DA_SUA_MAQUINA-QUE _SERA_ACESSADA:5900

  3. #3

    Padrão Não consigo redirecionar para o VNC ???

    Cara!

    Agora funcionou blz!!!

    Valeu pela ajuda...

  4. #4

    Padrão Não consigo redirecionar para o VNC ???

    ai, ó, tem visitante que ajuda também !

    amigo visitante, porque não se cadastra ?

  5. #5
    isique
    Visitante

    Padrão o que significa

    iporigem ???
    ipdestino ???
    ipqueseraacessada??


    antecipadamente
    agradeço