Dec 292016
 

Having OpenVPN server on your router is a nifty feature. However, as often with Mirotik, not all is straight forward.

This guide is going to assume you are to enter commands into the New Terminal window from WinBox. That way I will simply repeat commands needed instead of going through the screens. Commands are actually quite descriptive and easy to “translate” into GUI actions if that is your preference.

Prerequisite for any VPN server is to get certificates sorted. For OpenVPN we need main Certificate Authority, server, and client certificate. Yes, strictly speaking, client certificate is optional but let’s not skimp on security.

First we create all the certificate templates (10 years validity) we’ll need:

/certificate
add name=ca-template common-name=example.com days-valid=3650 key-size=2048 key-usage=crl-sign,key-cert-sign
add name=server-template common-name=*.example.com days-valid=3650 key-size=2048 key-usage=digital-signature,key-encipherment,tls-server
add name=client-template common-name=client.example.com days-valid=3650 key-size=2048 key-usage=tls-client

For the purpose of OpenVPN server common name can be really anything. However, some other VPNs are not as forgiving (yes SSTP, I am looking at you) so it might be best to have either your external IP or host name as the common-name text. Any yes, if you have dynamic IP and you are not using your own domain, you can put *.dyndns.org there – no worries.

Created certificates will need signing:

/certificate
sign ca-template name=ca-certificate
sign server-template name=server-certificate ca=ca-certificate
sign client-template name=client-certificate ca=ca-certificate

Depending on your router’s speed, that sign command might time-out – nothing to worry about – just wait for CPU to drop below 100%. Or alternatively check name of certificate – template part will disappear once signing is completed.

With this we need to export a few files:

/certificate
export-certificate ca-certificate export-passphrase=""
export-certificate client-certificate export-passphrase=12345678

This should give you three files: cert_export_ca-certificate.crt, cert_export_client-certificate.crt, and cert_export_client-certificate.key. After copying this on computer for later I like to rename them to ca.crt, client.crt, and client.key respectively.

Next we need a separate pool of IP addresses for clients. I will assume you have your clients in some other network (e.g. 192.168.1.x) and this new network is just for VPN:

/ip
pool add name="vpn-pool" ranges=192.168.8.10-192.168.8.99

Instead of editing the default encrypted profile, we can create a new one. Assumption is your Mikrotik will also be a DNS server. And while at it, you can create a bit more imaginative user/password:

/ppp
profile add name="vpn-profile" use-encryption=yes local-address=192.168.8.250 dns-server=192.168.8.250 remote-address=vpn-pool
secret add name=user profile=vpn-profile password=password

Finally, we can enable OpenVPN server interface:

/interface ovpn-server server
set default-profile=vpn-profile certificate=server-certificate require-client-certificate=yes auth=sha1 cipher=aes128,aes192,aes256 enabled=yes

Now finally we can copy both ca.crt and client.crt to C:\Program Files\OpenVPN\config\ directory alongside client.ovpn.

You don’t have client.ovpn? Well, one is in sample-config directory and we just need to change/add highlighted items:

client
dev tun
proto tcp
remote example.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
remote-cert-tls server
cipher AES-128-CBC
auth SHA1
auth-user-pass
redirect-gateway def1
verb 3

A bit annoying step is being asked for the private key passphrase (in the addition to username/password). Mikrotik doesn’t allow export without it but fortunately we can use OpenSSL to change that:

> openssl.exe rsa -in client.key -out client.key
Enter pass phrase for client.key: 12345678
writing RSA key

With this, your VPN connection should work like a charm.

PS: Do not forget to adjust firewall if necessary (TCP port 1194).

/ip firewall filter
add chain=input protocol=tcp dst-port=1194 action=accept place-before=0 comment="Allow OpenVPN"

PPS: Do check SSTP guide too.

[2017-01-26: Adjusted certificate creation to work on RouterOS 6.38 and later]
[2017-01-26: Changed key size to 2048 (instead of 4096) so it doesn’t take ages to generate certificates. :)]
[2017-02-25: Changed example to use AES-128 for lower CPU usage on router.]

  57 Responses to “Simple OpenVPN Server on Mikrotik”

Comments (56) Pingbacks (1)
  1. Because i had problems with TSL i added the following line to the .ovpn file
    tls-cipher DEFAULT

  2. Thanks! Worked perfectly.
    I just suggest to replace the port 1194 to 443 to bypass some firewall blocks.

  3. you are the best. may god be with you.

  4. “A bit annoying step is being asked for the private key passphrase (in the addition to username/password). Mikrotik doesn’t allow export without it but fortunately we can use OpenSSL to change that:

    > openssl.exe rsa -in client.key -out client.key
    Enter pass phrase for client.key: 12345678
    writing RSA key”

    Where do you do this step? On any linux system?

  5. Hi Josip,

    Is it possible to revoke the user certificate and block their vpn access on mikrotik side, instead of resetting the PPP Secret password? I tryed to revoke the user certificate on mikrotik but the user continue accessing the VPN!

    Thank you!

  6. Great OpenVPN tutorial. Thx

    I had run in to a problem regarding clients subnet. On widows client in log:

    There is a problem in your selection of –ifconfig endpoints [local=192.168.8.99, remote=192.168.8.250]. The local and remote VPN endpoints must exist within the same 255.255.255.252 subnet. This is a limitation of –dev tun when used with the TAP-WIN32 driver. Try ‘openvpn –show-valid-subnets’ option for more info.

    Problem was solved by moving pool to
    pool add name=”vpn-pool” ranges=192.168.8.240-192.168.8.249

  7. Thanks for the tutorial.

    Could I ask whether local-address=192.168.8.250 is the address of the Mikrotik box?

    My Mikrotik box is behind a router. The Router is 192.668.1.1, the Mokrotik box is 192.668.1.15. What local-address do I use?

    Charles

    • mistake…. should have been: The Router is 192.168.1.1, the Mikrotik box is 192.168.1.15

  8. Can someone help me please?
    I got this err message

    *input does not match any value of certificate*

    when running

    */interface ovpn-server server
    set default-profile=vpn-profile certificate=server-certificate require-client-certificate=yes auth=sha1 cipher=aes128,aes192,aes256 enabled=yes*

    What could be wrong ??

  9. Awesome, thank you ;)

  10. Hi Josip,

    I’m having issue with port 443, i can connect using other port (465 or 587) but for reason, 443 just kept getting rejected.

    Any ideas ?

    This is the error msg
    2017-11-09 13:49:19: TCP/UDP: Preserving recently used remote address: [AF_INET]61.0.0.000:443
    2017-11-09 13:49:19: Attempting to establish TCP connection with [AF_INET]61.0.0.000:443 [nonblock]
    2017-11-09 13:49:20: State changed to Disconnecting
    2017-11-09 13:49:20: SIGTERM[hard,init_instance] received, process exiting
    2017-11-09 13:49:20: State changed to Disconnected

  11. Hi, how about:

    client:
    Connection reset, restarting [0]
    Sun Nov 12 22:31:19 2017 us=380382 TCP/UDP: Closing socket
    Sun Nov 12 22:31:19 2017 us=380498 SIGUSR1[soft,connection-reset] received, process restarting

    server:
    : terminating… – could not add address list: empty list name not allowed (6)

  12. Thanks for the guide, I’m relatively inexperienced and have been trying to get OpenVPN to work and this is the closest I’ve come so far.

    I’ve set it all up and I can connect, but my Internet on the remote computer is being routed through the Mikrotik and I cannot access/ping the Mikrotik or any computers on the Mikrotik’s network. I want it to be the other way around.

    The Mikrotik manages the network 192.168.10.0/24 and the OpenVPN server is set up to give out address on 192.168.8.0/24. When I dial in via VPN, I only want traffic to 192.168.10.0/24 to be routed over the VPN, the rest (i.e. Internet) must NOT go through the VPN. How do I change your configuration to achieve this?

    • I don’t believe you can do it with Mikrotik’s configuration.

      What you want is split tunneling and that must be configured on connecting machine (afaik). There are a few guides about it on internet, e.g. this one.

      In short, you must set your computer to route only subset of addresses via VPN while all other are going over normal connection; e.g.192.168.0.0/16 via VPN; 0.0.0.0 via Normal.

  13. This is a great set up and seems to work just fine. However it seems to require a new profile for every device you want to connect. For instance if I wanted to connect both my phone and my laptop I would need two separate profiles (due to local address being static). Is there a way to set this up with the local address being a pool as well?

  14. Hi,
    seems that
    > sign ca-template name=ca-certificate
    needs some external certificate? Would be great to have this hinted in your doc :)

    -h

  15. Excellent tutorial – thank you very much :-)

    How can I set this up so that the VPN users can access computers on the LAN once the VPN has been established?

    -Aang

  16. hi
    thanks for your great tutorial

    I can’t connect to the server, the log file shows the error ” duplicate packet, dropping”!!
    what is the problem?????
    thank you

    • This usually indicates issue on client. Do check OpenVPN client log for clues.

      • here is log file for last try

        <<<8192] S=[8192->8192]
        Tue Jan 02 21:48:15 2018 us=902108 Attempting to establish TCP connection with [AF_INET]82.102.14.x:1194 [nonblock]
        Tue Jan 02 21:48:15 2018 us=902108 MANAGEMENT: >STATE:1514917095,TCP_CONNECT,,,,,,
        Tue Jan 02 21:48:16 2018 us=903165 TCP connection established with [AF_INET]82.102.14.x:1194
        Tue Jan 02 21:48:16 2018 us=903165 TCP_CLIENT link local: (not bound)
        Tue Jan 02 21:48:16 2018 us=903165 TCP_CLIENT link remote: [AF_INET]82.102.14.x:1194
        Tue Jan 02 21:48:16 2018 us=903165 MANAGEMENT: >STATE:1514917096,WAIT,,,,,,
        Tue Jan 02 21:48:16 2018 us=904165 MANAGEMENT: >STATE:1514917096,AUTH,,,,,,
        Tue Jan 02 21:48:16 2018 us=904165 TLS: Initial packet from [AF_INET]82.102.14.x:1194, sid=7846b6ff d01f4dd3

        >>>>>>>

        after last line the error message appears on server log

        thanks

        • try increasing debug level – e.g. by setting verb to 6 or higher.

          • thank you so much
            I set verb to 10 and this is log:

            <<len=0 wakeup=604800
            Fri Jan 05 11:35:10 2018 us=136129 ACK reliable_can_send active=1 current=0 : [2] 1
            Fri Jan 05 11:35:10 2018 us=136129 ACK reliable_send_timeout 8 [2] 1
            Fri Jan 05 11:35:10 2018 us=136129 TLS: tls_process: timeout set to 8
            Fri Jan 05 11:35:10 2018 us=136129 TLS: tls_multi_process: i=1 state=S_INITIAL, mysid=bf536d1c 5748c9b3, stored-sid=00000000 00000000, stored-ip=[AF_UNSPEC]
            Fri Jan 05 11:35:10 2018 us=136129 NOTE: –mute triggered…

            >>>

            much appreciated :)

          • the entire log does not show up here
            in the following link there is the log file in my Drive

            https://docs.google.com/document/d/1hZI72uBtfnhfWVEsPMQAjlCLxQ3_QCCO9IGq3_3mmW8/edit?usp=sharing

          • Based on your log, it seems server doesn’t like encryption options. It seems you are using cipher AES-256-CBC and server doesn’t like it. Please check if your mikrotik has aes256 enabled, either via UI or via command line:
            > /interface ovpn-server server
            > print
            enabled: yes
            port: 1194
            mode: ip
            netmask: 24
            mac-address: XX:XX:XX:XX:XX:XX
            max-mtu: 1500
            keepalive-timeout: 60
            default-profile: vpn-profile
            certificate: vpn-server-certificate
            require-client-certificate: yes
            auth: sha1
            cipher: aes128,aes256

          • thank you very much
            it has been connected successfully

            but my traffic does not go through ovpn
            based on this config what’s the problem?

            client
            dev tun
            proto tcp-client
            remote 82.102.14.x
            port 1194
            nobind
            persist-key
            persist-tun
            tls-client
            remote-cert-tls server
            ca cert_export_CA.crt
            cert cert_export_CLIENT1.crt
            key cert_export_CLIENT1.key
            mute 10
            cipher AES-256-CBC
            auth SHA1
            auth-user-pass secret
            auth-nocache
            redirect-gateway def1

          • It is probably related to routing. I would advise you to check your routing tables (on both client and router) and to snoop traffic on each.

            What usually works well for me is actually getting the simplest setup working before going to a more complicated one.

  17. I get the following error if i try to connect from Windows 7 to my Mikrotik:

    Sun Jan 28 20:23:28 2018 VERIFY OK: depth=1, CN=example.com
    Sun Jan 28 20:23:28 2018 VERIFY KU OK
    Sun Jan 28 20:23:28 2018 Validating certificate extended key usage
    Sun Jan 28 20:23:28 2018 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
    Sun Jan 28 20:23:28 2018 VERIFY EKU OK
    Sun Jan 28 20:23:28 2018 VERIFY OK: depth=0, CN=server
    Sun Jan 28 20:23:28 2018 Connection reset, restarting [0]
    Sun Jan 28 20:23:28 2018 SIGUSR1[soft,connection-reset] received, process restarting
    Sun Jan 28 20:23:28 2018 MANAGEMENT: >STATE:1517167408,RECONNECTING,connection-reset,,,,,
    Sun Jan 28 20:23:28 2018 Restart pause, 5 second(s)
    Sun Jan 28 20:23:33 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]84.112.18.105:1194
    Sun Jan 28 20:23:33 2018 Socket Buffers: R=[8192->8192] S=[8192->8192]
    Sun Jan 28 20:23:33 2018 Attempting to establish TCP connection with [AF_INET]IP-Address:1194 [nonblock]
    Sun Jan 28 20:23:33 2018 MANAGEMENT: >STATE:1517167413,TCP_CONNECT,,,,,,
    Sun Jan 28 20:23:34 2018 TCP connection established with [AF_INET]IP-Address:1194
    Sun Jan 28 20:23:34 2018 TCP_CLIENT link local: (not bound)
    Sun Jan 28 20:23:34 2018 TCP_CLIENT link remote: [AF_INET]IP-Address:1194
    Sun Jan 28 20:23:34 2018 MANAGEMENT: >STATE:1517167414,WAIT,,,,,,
    Sun Jan 28 20:23:34 2018 MANAGEMENT: >STATE:1517167414,AUTH,,,,,,
    Sun Jan 28 20:23:34 2018 TLS: Initial packet from [AF_INET]IP-Address:1194, sid=a66ddb54 61ca445f
    Sun Jan 28 20:23:36 2018 VERIFY OK: depth=1, CN=example.com
    Sun Jan 28 20:23:36 2018 VERIFY KU OK
    Sun Jan 28 20:23:36 2018 Validating certificate extended key usage

    Does anyone have an idea whtat is wrong ?

    Chris

  18. hello
    my vpn connected but no internet acces . im using vps mikrotik can you help me?

  19. To the point, thank you!

  20. Excellent post. I have follow a lot of tutorials but it all give me the exact same “error”. Can someone help?

    Mon Feb 19 18:06:30 2018 OpenVPN 2.3.18 x86_64-w64-mingw32 [SSL (OpenSSL)] [LZO] [PKCS11] [IPv6] built on Oct 26 2017
    Mon Feb 19 18:06:30 2018 Windows version 6.2 (Windows 8 or greater) 64bit
    Mon Feb 19 18:06:30 2018 library versions: OpenSSL 1.0.2l 25 May 2017, LZO 2.10
    Enter Management Password:
    Mon Feb 19 18:06:30 2018 MANAGEMENT: TCP Socket listening on [AF_INET]127.0.0.1:25340
    Mon Feb 19 18:06:30 2018 Need hold release from management interface, waiting…
    Mon Feb 19 18:06:30 2018 MANAGEMENT: Client connected from [AF_INET]127.0.0.1:25340
    Mon Feb 19 18:06:30 2018 MANAGEMENT: CMD ‘state on’
    Mon Feb 19 18:06:30 2018 MANAGEMENT: CMD ‘log all on’
    Mon Feb 19 18:06:30 2018 MANAGEMENT: CMD ‘hold off’
    Mon Feb 19 18:06:30 2018 MANAGEMENT: CMD ‘hold release’
    Mon Feb 19 18:06:36 2018 MANAGEMENT: CMD ‘username “Auth” “s.messias”‘
    Mon Feb 19 18:06:36 2018 MANAGEMENT: CMD ‘password […]’
    Mon Feb 19 18:06:38 2018 MANAGEMENT: CMD ‘password […]’
    Mon Feb 19 18:06:38 2018 WARNING: this configuration may cache passwords in memory — use the auth-nocache option to prevent this
    Mon Feb 19 18:06:38 2018 Socket Buffers: R=[65536->65536] S=[65536->65536]
    Mon Feb 19 18:06:38 2018 MANAGEMENT: >STATE:1519063598,RESOLVE,,,
    Mon Feb 19 18:06:40 2018 Attempting to establish TCP connection with [AF_INET]109.51.161.49:1194 [nonblock]
    Mon Feb 19 18:06:40 2018 MANAGEMENT: >STATE:1519063600,TCP_CONNECT,,,
    Mon Feb 19 18:06:50 2018 TCP: connect to [AF_INET]109.51.161.49:1194 failed, will try again in 5 seconds: Connection timed out (WSAETIMEDOUT)
    Mon Feb 19 18:06:55 2018 MANAGEMENT: >STATE:1519063615,RESOLVE,,,
    Mon Feb 19 18:06:55 2018 MANAGEMENT: >STATE:1519063615,TCP_CONNECT,,,
    Mon Feb 19 18:07:05 2018 TCP: connect to [AF_INET]109.51.161.49:1194 failed, will try again in 5 seconds: Connection timed out (WSAETIMEDOUT)
    Mon Feb 19 18:07:10 2018 MANAGEMENT: >STATE:1519063630,RESOLVE,,,
    Mon Feb 19 18:07:10 2018 MANAGEMENT: >STATE:1519063630,TCP_CONNECT,,,
    Mon Feb 19 18:07:20 2018 TCP: connect to [AF_INET]109.51.161.49:1194 failed, will try again in 5 seconds: Connection timed out (WSAETIMEDOUT)
    Mon Feb 19 18:07:25 2018 MANAGEMENT: >STATE:1519063645,RESOLVE,,,
    Mon Feb 19 18:07:25 2018 MANAGEMENT: >STATE:1519063645,TCP_CONNECT,,,
    Mon Feb 19 18:07:35 2018 TCP: connect to [AF_INET]109.51.161.49:1194 failed, will try again in 5 seconds: Connection timed out (WSAETIMEDOUT)

    • As a first suggestion install latest OpenVPN client (2.4.4). Don’t use old clients. Can you post config details for server and client? Use e-mail If you wish privacy.

      Br

      Sasa

  21. really simple & helpful, Thx a lot.

  22. I don’t connect to ipfire firewall as client, can you help me? Thanks a lot

  23. Man, you rock!
    Works like a charm!

    Many many thanks!!!

  24. In command sign client-template name=client-certificate ca=ca-certificate i have got the message failure: name must be unique!. Whats my wrong?

  25. Messages from openvpn. Cant connect. Whats the problem? Thanks

    Fri Mar 16 17:58:45 2018 TCP_CLIENT link local: (not bound)
    Fri Mar 16 17:58:45 2018 TCP_CLIENT link remote: [AF_INET]192.168.2.121:1194
    Fri Mar 16 17:58:45 2018 MANAGEMENT: >STATE:1521215925,WAIT,,,,,,
    Fri Mar 16 17:58:45 2018 MANAGEMENT: >STATE:1521215925,AUTH,,,,,,
    Fri Mar 16 17:58:45 2018 TLS: Initial packet from [AF_INET]192.168.2.121:1194, sid=be91e965 fa86d7f8
    Fri Mar 16 17:58:47 2018 VERIFY OK: depth=1, CN=example.com
    Fri Mar 16 17:58:47 2018 VERIFY KU OK
    Fri Mar 16 17:58:47 2018 Validating certificate extended key usage
    Fri Mar 16 17:58:47 2018 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
    Fri Mar 16 17:58:47 2018 VERIFY EKU OK
    Fri Mar 16 17:58:47 2018 VERIFY OK: depth=0, CN=casiosp.dvrdns.org
    Fri Mar 16 17:58:47 2018 Connection reset, restarting [0]
    Fri Mar 16 17:58:47 2018 SIGUSR1[soft,connection-reset] received, process restarting
    Fri Mar 16 17:58:47 2018 MANAGEMENT: >STATE:1521215927,RECONNECTING,connection-reset,,,,,
    Fri Mar 16 17:58:47 2018 Restart pause, 10 second(s)
    Fri Mar 16 17:58:57 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.2.121:1194
    Fri Mar 16 17:58:57 2018 Socket Buffers: R=[65536->65536] S=[65536->65536]
    Fri Mar 16 17:58:57 2018 Attempting to establish TCP connection with [AF_INET]192.168.2.121:1194 [nonblock]
    Fri Mar 16 17:58:57 2018 MANAGEMENT: >STATE:1521215937,TCP_CONNECT,,,,,,
    Fri Mar 16 17:58:58 2018 TCP connection established with [AF_INET]192.168.2.121:1194
    Fri Mar 16 17:58:58 2018 TCP_CLIENT link local: (not bound)
    Fri Mar 16 17:58:58 2018 TCP_CLIENT link remote: [AF_INET]192.168.2.121:1194
    Fri Mar 16 17:58:58 2018 MANAGEMENT: >STATE:1521215938,WAIT,,,,,,
    Fri Mar 16 17:58:58 2018 MANAGEMENT: >STATE:1521215938,AUTH,,,,,,
    Fri Mar 16 17:58:58 2018 TLS: Initial packet from [AF_INET]192.168.2.121:1194, sid=68f041e5 8c91330d
    Fri Mar 16 17:59:00 2018 VERIFY OK: depth=1, CN=example.com
    Fri Mar 16 17:59:00 2018 VERIFY KU OK
    Fri Mar 16 17:59:00 2018 Validating certificate extended key usage
    Fri Mar 16 17:59:00 2018 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
    Fri Mar 16 17:59:00 2018 VERIFY EKU OK
    Fri Mar 16 17:59:00 2018 VERIFY OK: depth=0, CN=casiosp.dvrdns.org
    Fri Mar 16 17:59:01 2018 Connection reset, restarting [0]
    Fri Mar 16 17:59:01 2018 SIGUSR1[soft,connection-reset] received, process restarting
    Fri Mar 16 17:59:01 2018 MANAGEMENT: >STATE:1521215941,RECONNECTING,connection-reset,,,,,
    Fri Mar 16 17:59:01 2018 Restart pause, 20 second(s)
    Fri Mar 16 17:59:21 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.2.121:1194
    Fri Mar 16 17:59:21 2018 Socket Buffers: R=[65536->65536] S=[65536->65536]
    Fri Mar 16 17:59:21 2018 Attempting to establish TCP connection with [AF_INET]192.168.2.121:1194 [nonblock]
    Fri Mar 16 17:59:21 2018 MANAGEMENT: >STATE:1521215961,TCP_CONNECT,,,,,,
    Fri Mar 16 17:59:22 2018 TCP connection established with [AF_INET]192.168.2.121:1194
    Fri Mar 16 17:59:22 2018 TCP_CLIENT link local: (not bound)
    Fri Mar 16 17:59:22 2018 TCP_CLIENT link remote: [AF_INET]192.168.2.121:1194
    Fri Mar 16 17:59:22 2018 MANAGEMENT: >STATE:1521215962,WAIT,,,,,,
    Fri Mar 16 17:59:22 2018 MANAGEMENT: >STATE:1521215962,AUTH,,,,,,
    Fri Mar 16 17:59:22 2018 TLS: Initial packet from [AF_INET]192.168.2.121:1194, sid=13c51eb4 ef70e5e6
    Fri Mar 16 17:59:23 2018 VERIFY OK: depth=1, CN=example.com
    Fri Mar 16 17:59:23 2018 VERIFY KU OK
    Fri Mar 16 17:59:23 2018 Validating certificate extended key usage
    Fri Mar 16 17:59:23 2018 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
    Fri Mar 16 17:59:23 2018 VERIFY EKU OK
    Fri Mar 16 17:59:23 2018 VERIFY OK: depth=0, CN=casiosp.dvrdns.org
    Fri Mar 16 17:59:24 2018 Connection reset, restarting [0]
    Fri Mar 16 17:59:24 2018 SIGUSR1[soft,connection-reset] received, process restarting
    Fri Mar 16 17:59:24 2018 MANAGEMENT: >STATE:1521215964,RECONNECTING,connection-reset,,,,,
    Fri Mar 16 17:59:24 2018 Restart pause, 40 second(s)

  26. Attempting to execute “sign client-template name=client-certificate ca=ca-certificate” I get:

    “failure: certificate with the same subject exists!”

    Thus, this cannot be signed.

    Any suggestions?

    • Just use different name – you already has certificate named the same as one you are attempting to create from template.

      • Thanks. We used a workaround and have it working.

        For the future – which field is the subject or name?

        Appreciate the instructions on this.

  27. Hey Josip,

    After running the export commands I only see two files: cert_export_ca-certificate.crt and cert_export_client-certificate.crt. There is no cert_export_client-certificate.key. Any ideas what’s wrong?

  28. Thanks for your submission!
    We got an error:
    Thu Apr 05 09:28:51 2018 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
    Thu Apr 05 09:28:51 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]195.167.110.45:1194
    Thu Apr 05 09:28:51 2018 Attempting to establish TCP connection with [AF_INET]########## [nonblock]
    Thu Apr 05 09:28:52 2018 TCP connection established with [AF_INET]##################
    Thu Apr 05 09:28:52 2018 TCP_CLIENT link local: (not bound)
    Thu Apr 05 09:28:52 2018 TCP_CLIENT link remote: [AF_INET]##################
    Thu Apr 05 09:28:54 2018 VERIFY ERROR: depth=0, error=unsupported certificate purpose: C=##, O=####, CN=##
    Thu Apr 05 09:28:54 2018 OpenSSL: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
    Thu Apr 05 09:28:54 2018 TLS_ERROR: BIO read tls_read_plaintext error
    Thu Apr 05 09:28:54 2018 TLS Error: TLS object -> incoming plaintext read error
    Thu Apr 05 09:28:54 2018 TLS Error: TLS handshake failed
    Thu Apr 05 09:28:54 2018 Fatal TLS error (check_tls_errors_co), restarting
    Thu Apr 05 09:28:54 2018 SIGUSR1[soft,tls-error] received, process restarting

    Well, the solution is included in the log:
    https://openvpn.net/index.php/open-source/documentation/howto.html#mitm

  29. Hey thanks for the great post, this is an excellent walkthrough.

    I am getting an error when I try to connect:

    “Key file (‘client.key’) can be a maximum of 2048 bytes”

    I have searched for a good hour now and not come up with any solution, do you know what would be causing this?

  30. Hi! Thank you so much for this post! I’m connecting to my vpn and can see that my address is the static one (where my servers and Mikrotik are).

    The only problem is that I’m not being able to do ssh or use RDP to the other machines that are on my remote end (my servers).

    Seems to be something about routing, but I don’t know that much :/

    Any tips?

    • I’m having this same issue.. I cannot access any server I have on the network I’m VPN’ing into. Internet access work but no access to local network machines.

      Does anyone have any insight into how to access local machines on the local network we are VPN’ing into using this tutorial?

      Much thanks in advance!

  31. Same problem as Jhon…..

  32. There is need to set NAT masquarade for srcnat chain with OpenVPN as a source network

  33. Works a treat. Searched everywhere for decent instructions – this hits the spot. Well done, and thanks!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>