1

I run OpenVPN in Win7 as a service in background. For years now this worked fine, the connection was always automatically re-established and this is how it should be.

However, suddenly this does not work any more! When the connection drops (e.g., the laptop goes to standby) I always need to stop and restart the service in order to re-establish the connection.

The connection establishes successfully:

Wed Jun 24 10:26:58 2015 OpenVPN 2.3.7 x86_64-w64-mingw32 [SSL (OpenSSL)] [LZO] [PKCS11] [IPv6] built on Jun  8 2015
Wed Jun 24 10:26:58 2015 library versions: OpenSSL 1.0.1m 19 Mar 2015, LZO 2.08
Wed Jun 24 10:26:58 2015 UDPv4 link local (bound): [undef]
Wed Jun 24 10:26:58 2015 UDPv4 link remote: [AF_INET]53.33.202.70:500
Wed Jun 24 10:26:58 2015 VERIFY OK: depth=1, C=US, ST=CA, L=SF, emailAddress=admin@localhost
Wed Jun 24 10:26:58 2015 VERIFY OK: nsCertType=SERVER
Wed Jun 24 10:26:58 2015 VERIFY OK: depth=0, C=US, ST=CA, L=SF, emailAddress=admin@localhost
Wed Jun 24 10:26:59 2015 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Wed Jun 24 10:26:59 2015 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Jun 24 10:26:59 2015 NOTE: --mute triggered...
Wed Jun 24 10:26:59 2015 3 variation(s) on previous 5 message(s) suppressed by --mute
Wed Jun 24 10:26:59 2015 [server] Peer Connection Initiated with [AF_INET]53.33.202.70:500
Wed Jun 24 10:27:01 2015 open_tun, tt->ipv6=0
Wed Jun 24 10:27:01 2015 TAP-WIN32 device [OpenVPN] opened: \\.\Global\{6C3D3D35-743E-4239-BFD8-143837009EBE}.tap
Wed Jun 24 10:27:01 2015 Sleeping for 3 seconds...
Wed Jun 24 10:27:04 2015 Successful ARP Flush on interface [28] {6C3D3D35-743E-4239-BFD8-143837009EBE}
Wed Jun 24 10:27:09 2015 Initialization Sequence Completed

Then, when the connection drops, instead of reconnecting, the following appears in the logs:

Wed Jun 24 11:14:40 2015 TUN/TAP I/O operation aborted, exiting
Wed Jun 24 11:14:40 2015 Exiting due to fatal error
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Warning: route gateway is not reachable on any active network adapters: 192.168.200.120
Wed Jun 24 11:14:40 2015 env_block: add PATH=C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
Wed Jun 24 11:14:40 2015 Closing TUN/TAP interface

How to fix this?

5
  • Wouldn't that be related to disabling your network card due to power saving ? – Maciej Asembler Jun 26 '15 at 19:28
  • I don't know what you mean. The point is: Whenever the connection is disconnected it should automatically reconnect again. And this happened for years except now. – divB Jun 26 '15 at 23:35
  • The error message explains it all - tun/tap can't perform an I/O operation and can't access gateway on default route. Your network adapters must have been disabled somehow. I can propose turning off power saving options on your network cards in device manager or resetting IPv4 stack on your Windows7 – Maciej Asembler Jun 27 '15 at 11:51
  • Not to me ;-) There are often cases when the gateway can't be accessed. However, in this case it must keep trying until it is (which was the case so far to my knowledge). Also which network adapters? Wifi and LAN adapters or the virtual tun/tap? I think not but even if - I think it's supposed to be keep on trying until they are active again. And I still wonder why this just started to happen... – divB Jun 27 '15 at 14:34
  • 1
    openvpnserv2.exe has been integrated into OpenVPN 2.4. Try it out. – arrowd Jan 9 '17 at 8:57
2

There is some known issues with Open VPN client when Windows gets to sleep or hibernation mode. The openvpn service get's killed by network being shutdown in sleep mode and is not restarted. See :

The solution is to use a other service windows manager that check openvpn client service in fact running, and restart it if is not. The OpenVPN team is working on integrating NSSM (the Non-Sucking Service Manager) in the OpenVPN client installation for Windows to provide a efficient service management, but it not included yet (currently version 2.8.3).

As explained in the following wiki page :

You have to use NSSM to manage the openvpn service :

  1. Download NSSM binary in the 'C:\Program Files\OpenVPN\bin' folder
  2. Create a batch file containing :

    set BASEDIR=C:\Program Files\OpenVPN
    set NSSM=%BASEDIR%\bin\nssm.exe
    set CONN=community.ovpn
    "%NSSM%" status %CONN% > NUL 2>&1
    if %ERRORLEVEL% EQU 3 (
        "%NSSM%" install %CONN% "%BASEDIR%\bin\openvpn.exe" > NUL 2>&1
    )
    "%NSSM%" set %CONN% AppDirectory "%BASEDIR%\config" > NUL 2>&1
    "%NSSM%" set %CONN% AppParameters "--config %CONN%" > NUL 2>&1
    "%NSSM%" set %CONN% AppStdin "%BASEDIR%\log\%CONN%.log" > NUL 2>&1
    "%NSSM%" set %CONN% AppStdout "%BASEDIR%\log\%CONN%.log" > NUL 2>&1
    "%NSSM%" set %CONN% AppStderr "%BASEDIR%\log\%CONN%.log" > NUL 2>&1
    "%NSSM%" set %CONN% AppRotateFiles 1 > NUL 2>&1
    "%NSSM%" set %CONN% DependOnService Dhcp tap0901 > NUL 2>&1
    "%NSSM%" start %CONN% > NUL 2>&1 
    
  3. Check carefully the CONN variable : it should be your openvpn client configuration.

  4. Run the batch file in a command line terminal launched as administrator.

This will install a nssm service looking up for your open vpn client configuration. You only need to run this batch once.

If you added by mistake a nssm service on the work vpn config, you can remove it with the following command.

nssm remove <connection>

For instance :

nssm remove community.ovpn

Check the tasks manager process tab to see which nssm processes are running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.