Partage
  • Partager sur Facebook
  • Partager sur Twitter

Connexion refusée openvpn

Sujet résolu
    26 janvier 2017 à 18:31:37

    Bonjour à tous, 

    J'ai récemment voulu installer mon propre vpn sur mon serveur, qui tourne actuellement sous debian 8. 

    j'ai suivis à la lettre (ou presque) ce tuto : 

    https://openclassrooms.com/courses/creer-son-propre-serveur-vpn-avec-open-vpn

    Je dis bien presque car :

    cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/

    Ne fonctionne pas, le dossier n'existe pas, je suppose que c'est du aux majs....

    Du coup j'ai fais un copié collé de /usr/share/easy-rsa dans /etc/openvpn/ à la place...

    Le reste fonctionne bien, mise à par le changement de la clé 1028bits, en 2048bits. 

    Au niveau conf je suis comme ceci pour le server.conf : 

    #############################
        #       Configuration       #
        #           VPN             #
        #############################
         
        # port et mode
        mode server
        proto tcp
        port 443
        dev tun
         
        # certificats + cles
        ca ca.crt
        cert server.crt
        key server.key
        dh dh2048.pem
        tls-auth ta.key 0
        cipher AES-256-CBC
         
        # Config reseau
        server 10.8.0.0 255.255.255.0
        push "redirect-gateway def1 bypass-dhcp"
        push "dhcp-option DNS 80.67.169.12"
        push "dhcp-option DNS 80.67.169.40"
        keepalive 10 120
         
        # Config securite
        user nobody
        group nogroup
        chroot /etc/openvpn/jail
        persist-key
        persist-tun
        comp-lzo
         
        # Config des logs
        verb 3
        mute 20
        status openvpn-status.log
        log-append /var/log/openvpn.log
    

    Pour le client.conf / client.ovpn : 

    # Config Client
    client
    dev tun
    proto tcp-client
    remote 'ipserver' 443
    resolv-retry infinite
    cipher AES-256-CBC
    # Certificats + Cles
    ca ca.crt
    cert pysn.crt
    key pysn.key
    tls-auth ta.key 1
    # Config Securite
    nobind
    persist-key
    persist-tun
    comp-lzo
    verb 3


    Pour le reste je suis clean, normalement...

    Le problème ne vient pas du firewall du serveur, car même à zéro je peux pas m'y connecter. 

    Un telnet server 443 sur mon mac me retourne :

    Trying server...

    telnet: connect to address server: Connection refused

    D'autre part, j'utilise tunnelblick pour m'y connecter.

    Il me retourne ceci :

    2017-01-26 18:14:39 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
    
    2017-01-26 18:14:39 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
    2017-01-26 18:14:39 Control Channel Authentication: using 'ta.key' as a OpenVPN static key file
    2017-01-26 18:14:39 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
    2017-01-26 18:14:39 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
    2017-01-26 18:14:39 Socket Buffers: R=[131072->131072] S=[131072->131072]
    2017-01-26 18:14:39 Attempting to establish TCP connection with [AF_INET]server:443 [nonblock]
    2017-01-26 18:14:39 MANAGEMENT: >STATE:1485450879,TCP_CONNECT,,,
    2017-01-26 18:14:40 TCP: connect to [AF_INET]server:443 failed, will try again in 5 seconds: Connection refused
     
    
    2017-01-26 18:14:45 MANAGEMENT: >STATE:1485450885,TCP_CONNECT,,,

    J'ai testé également 

    openvpn /etc/openvpn/clientconf/pysn/client.conf
    

    et pareil, impossible de se connecter... 

    Sincèrement, je ne vois pas le soucis... 

    Merci à vous ! 

    J'ai bêtement changé de port et c'est bon je m'y connecte....

    Problème, une fois connecté, impossible d'aller sur internet... D'ou pourrait venir le soucis de mon côté ? 

    voilà ce que me retourne un openvpn client.conf : 

    Thu Jan 26 21:14:22 2017 OpenVPN 2.3.4 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Nov 12 2015
    
    Thu Jan 26 21:14:22 2017 library versions: OpenSSL 1.0.1t  3 May 2016, LZO 2.08
    
    Thu Jan 26 21:14:22 2017 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
    
    Thu Jan 26 21:14:22 2017 Control Channel Authentication: using 'ta.key' as a OpenVPN static key file
    
    Thu Jan 26 21:14:22 2017 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
    
    Thu Jan 26 21:14:22 2017 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
    
    Thu Jan 26 21:14:22 2017 Socket Buffers: R=[87380->131072] S=[16384->131072]
    
    Thu Jan 26 21:14:22 2017 Attempting to establish TCP connection with [AF_INET]XXXX:1300 [nonblock]
    
    Thu Jan 26 21:14:22 2017 TCP connection established with [AF_INET]XXXXX:1300
    
    Thu Jan 26 21:14:22 2017 TCPv4_CLIENT link local: [undef]
    
    Thu Jan 26 21:14:22 2017 TCPv4_CLIENT link remote: [AF_INET]XXXX:1300
    
    Thu Jan 26 21:14:22 2017 TLS: Initial packet from [AF_INET]XXXX:1300, sid=283fcafb ee321f35
    
    Thu Jan 26 21:14:22 2017 VERIFY OK: depth=1, C=FR, ST=FR, L=Paris, O=Paris, OU=VPN, CN=Paris CA, name=EasyRSA, emailAddress=
    
    Thu Jan 26 21:14:22 2017 VERIFY OK: depth=0, C=FR, ST=FR, L=Paris, O=Paris, OU=VPN, CN=server, name=EasyRSA, emailAddress=
    
    Thu Jan 26 21:14:22 2017 Data Channel Encrypt: Cipher 'AES-256-CBC' initialized with 256 bit key
    
    Thu Jan 26 21:14:22 2017 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
    
    Thu Jan 26 21:14:22 2017 Data Channel Decrypt: Cipher 'AES-256-CBC' initialized with 256 bit key
    
    Thu Jan 26 21:14:22 2017 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
    
    Thu Jan 26 21:14:22 2017 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
    
    Thu Jan 26 21:14:22 2017 [server] Peer Connection Initiated with [AF_INET]XXXX:1300
    
    Thu Jan 26 21:14:24 2017 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
    
    Thu Jan 26 21:14:24 2017 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 208.67.222.222,dhcp-option DNS 208.67.220.220,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5'
    
    Thu Jan 26 21:14:24 2017 OPTIONS IMPORT: timers and/or timeouts modified
    
    Thu Jan 26 21:14:24 2017 OPTIONS IMPORT: --ifconfig/up options modified
    
    Thu Jan 26 21:14:24 2017 OPTIONS IMPORT: route options modified
    
    Thu Jan 26 21:14:24 2017 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
    
    Thu Jan 26 21:14:24 2017 ROUTE_GATEWAY X.X.X.254/255.255.255.0 IFACE=eth0 HWADDR=00:22:4d:aa:c9:ef
    
    Thu Jan 26 21:14:24 2017 TUN/TAP device tun1 opened
    
    Thu Jan 26 21:14:24 2017 TUN/TAP TX queue length set to 100
    
    Thu Jan 26 21:14:24 2017 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
    
    Thu Jan 26 21:14:24 2017 /sbin/ip link set dev tun1 up mtu 1500
    
    Thu Jan 26 21:14:25 2017 /sbin/ip addr add dev tun1 local 10.8.0.6 peer 10.8.0.5
    
    Thu Jan 26 21:14:25 2017 /sbin/ip route add XXXX/32 via XXX.254
    
    Thu Jan 26 21:14:25 2017 /sbin/ip route add 0.0.0.0/1 via 10.8.0.5



    -
    Edité par PySN 26 janvier 2017 à 21:21:29

    • Partager sur Facebook
    • Partager sur Twitter
      8 février 2017 à 10:15:54

      Salut,

      Est ce que tu as modifié tes règles iptable pour autorisé le redirection de traffic et activé le fowarding ?

      https://doc.ubuntu-fr.org/openvpn#acceder_a_internet_par_votre_vpn

      • Partager sur Facebook
      • Partager sur Twitter
        23 février 2017 à 14:56:20

        Bonjour, 

        Merci de ta réponse, le problème est désormais réglé ;) 

        Je pense que c'est au niveau du firewall que ça bloquait... 

        Peu importe, avec les règles suivantes, ça fonctionne : 

        iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to "ipserver"
        iptables -I INPUT -p UDP --dport "portvpn" -j ACCEPT
        iptables -I FORWARD -s 10.8.0.0/24 -j ACCEPT
        iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

        Si quelqu'un passe par là, sache qu'il ne faut pas laisser les guillemets au niveau de ipserver et portvpn. 

        De plus, je link ce petit script (à modifier selon les besoins) qui vous permettra d'installer openvpn très très simplement et rapidement en évitant de se casser la tête sur des tutos un peu anciens désormais...

        c'est d'ailleurs via ce script que j'ai trouvé les règles pour mon script iptables. 

        https://github.com/Nyr/openvpn-install

        • Partager sur Facebook
        • Partager sur Twitter

        Connexion refusée openvpn

        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
        • Editeur
        • Markdown