R7000 - VPN disconnects - no auto reconnect

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2
Author Message
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12881
Location: Netherlands

PostPosted: Wed Apr 26, 2017 10:14    Post subject: Reply with quote
mac913 wrote:
Keepalive basically uses ping & ping-restart commands but the persist-tun command disallows it for doing it's job. I believe the TUN/TAP connection needs to restart for the reconnection start up correctly.

The server should take care of any ping and ping-restart so I don't think the client needs it. Also persist-remote-ip is useful for static IPs but can be a problem for dynamic IPs which most VPN Services providers use. I have described persist-tun which doesn't like to 'let-go' of the TUN/TAP connection.

I've created a script without keepalive,ping,ping-restart,persist-tun & persist-remote-ip in the openvpn configuration to see if I will get a constant re-connect when it needed to from the VPN server.


The main culprit could be
Code:
persist remote ip
at least for PIA do not use it. Use only the settings (for PIA) I posted earlier Smile
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Sponsor
Blacksheep
DD-WRT Novice


Joined: 14 Nov 2007
Posts: 24

PostPosted: Mon May 29, 2017 16:11    Post subject: Reply with quote
Hi guys.

I hope you dont mind me jumping in, but this is the thread which matches my current problem most. Therefore I hope you could share your solution, if you found it in the end.

I am running Kong's DD-WRT version v3.0-r31900M (on a Linksys EA8500). I have OpenVPN client up and running with my PIA subscribtion. However about every 24-26 hours, the connection is lost because of: "AUTH: Received control message: AUTH_FAILED".

I have tried the additional config provided by PIA (also listed earlier in this thread). Tried it with and without "persist-tun" and/or "auth-retry nointeract". I have also tried using the additional config provided by egc instead. Using the latter, I receive the following errors in the syslog:

Code:
May 29 16:25:04 Linksys EA8500 daemon.notice openvpn[29744]: [6e3389298c82e01bb930fa65a53a2e61] Inactivity timeout (--ping-restart), restarting
May 29 16:25:04 Linksys EA8500 daemon.notice openvpn[29744]: SIGUSR1[soft,ping-restart] received, process restarting
May 29 16:25:04 Linksys EA8500 daemon.notice openvpn[29744]: Restart pause, 5 second(s)
May 29 16:25:09 Linksys EA8500 daemon.warn openvpn[29744]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: TCP/UDP: Preserving recently used remote address: [AF_INET]5.157.7.178:1198
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: Socket Buffers: R=[180224->360448] S=[180224->360448]
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: UDPv4 link local: (not bound)
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: UDPv4 link remote: [AF_INET]5.157.7.178:1198
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: VERIFY OK: depth=1, C=US, ST=CA, L=LosAngeles, O=Private Internet Access, OU=Private Internet Access, CN=Private Internet Access, name=Private Internet Access, emailAddress=secure@privateinternetaccess.com
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: VERIFY KU OK
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: NOTE: --mute triggered...
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: 5 variation(s) on previous 3 message(s) suppressed by --mute
May 29 16:25:09 Linksys EA8500 daemon.notice openvpn[29744]: [6e3389298c82e01bb930fa65a53a2e61] Peer Connection Initiated with [AF_INET]5.157.7.178:1198
May 29 16:25:11 Linksys EA8500 daemon.notice openvpn[29744]: SENT CONTROL [6e3389298c82e01bb930fa65a53a2e61]: 'PUSH_REQUEST' (status=1)
May 29 16:25:11 Linksys EA8500 daemon.notice openvpn[29744]: AUTH: Received control message: AUTH_FAILED
May 29 16:25:11 Linksys EA8500 daemon.notice openvpn[29744]: /tmp/openvpncl/route-down.sh tun1 1500 1622 10.32.10.6 10.32.10.5 init
May 29 16:25:11 Linksys EA8500 daemon.notice openvpn[29744]: Closing TUN/TAP interface
May 29 16:25:11 Linksys EA8500 daemon.notice openvpn[29744]: /sbin/ifconfig tun1 0.0.0.0
May 29 16:25:11 Linksys EA8500 daemon.notice openvpn[29744]: SIGTERM[soft,auth-failure] received, process exiting


I am not sure what the issue is, but I also suspect, that it has something to do with PIA using dynamic IPs. Which is great, except the line in my syslog:

Code:
TCP/UDP: Preserving recently used remote address: [AF_INET]5.157.7.178:1198

That seems to indicate, that the "persist remote ip" is set somewhere (in the default connection settings perhaps?).
Also I hoped, that the config "keepalive 10 120" would re-resolve the hostname so as to not just use the same IP address?

Any help here is appreciated, since I have been toying around with different settings for almost 2 weeks now. Thanks.

Edit: I found the original post from user "sploit", who egc was refering to, here: https://www.dd-wrt.com/phpBB2/viewtopic.php?p=1076048#1076048
I am now trying with all the settings sploit suggested (except comp-lzo since that is already set through the GUI).
Blacksheep
DD-WRT Novice


Joined: 14 Nov 2007
Posts: 24

PostPosted: Tue May 30, 2017 15:55    Post subject: Reply with quote
Crying or Very sad So unfortunately, even when using all the settings from sploit, the connection still disconnects after about 24 hours:

Code:
May 30 16:38:05 Linksys EA8500 daemon.notice openvpn[2202]: [697a2631d36dca8eff022955d655caa6] Inactivity timeout (--ping-restart), restarting
May 30 16:38:05 Linksys EA8500 daemon.notice openvpn[2202]: Restart pause, 5 second(s)
May 30 16:38:10 Linksys EA8500 daemon.warn openvpn[2202]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: TCP/UDP: Preserving recently used remote address: [AF_INET]91.108.183.74:1198
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: Socket Buffers: R=[180224->360448] S=[180224->360448]
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: UDPv4 link local: (not bound)
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: UDPv4 link remote: [AF_INET]91.108.183.74:1198
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: TLS: Initial packet from [AF_INET]91.108.183.74:1198, sid=44d7c8dd 50b0c738
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: VERIFY OK: depth=1, C=US, ST=CA, L=LosAngeles, O=Private Internet Access, OU=Private Internet Access, CN=Private Internet Access, name=Private Internet Access, emailAddress=secure@privateinternetaccess.com
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: VERIFY KU OK
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: NOTE: --mute triggered...
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: 5 variation(s) on previous 3 message(s) suppressed by --mute
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: [697a2631d36dca8eff022955d655caa6] Peer Connection Initiated with [AF_INET]91.108.183.74:1198
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: SENT CONTROL [697a2631d36dca8eff022955d655caa6]: 'PUSH_REQUEST' (status=1)
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: AUTH: Received control message: AUTH_FAILED
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: /tmp/openvpncl/route-down.sh tun1 1500 1622 10.41.10.6 10.41.10.5 init
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: Closing TUN/TAP interface
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: /sbin/ifconfig tun1 0.0.0.0
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: SIGTERM[soft,auth-failure] received, process exiting


I am now officially out of ideas. I think I will post a new subject in the "Advanced Networking" subforum, to get more eyes on it.
tmo1138
DD-WRT User


Joined: 24 Mar 2015
Posts: 175
Location: Tacoma, Wa

PostPosted: Tue May 30, 2017 16:49    Post subject: Reply with quote
Blacksheep wrote:
Crying or Very sad So unfortunately, even when using all the settings from sploit, the connection still disconnects after about 24 hours:

Code:
May 30 16:38:05 Linksys EA8500 daemon.notice openvpn[2202]: [697a2631d36dca8eff022955d655caa6] Inactivity timeout (--ping-restart), restarting
May 30 16:38:05 Linksys EA8500 daemon.notice openvpn[2202]: Restart pause, 5 second(s)
May 30 16:38:10 Linksys EA8500 daemon.warn openvpn[2202]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: TCP/UDP: Preserving recently used remote address: [AF_INET]91.108.183.74:1198
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: Socket Buffers: R=[180224->360448] S=[180224->360448]
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: UDPv4 link local: (not bound)
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: UDPv4 link remote: [AF_INET]91.108.183.74:1198
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: TLS: Initial packet from [AF_INET]91.108.183.74:1198, sid=44d7c8dd 50b0c738
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: VERIFY OK: depth=1, C=US, ST=CA, L=LosAngeles, O=Private Internet Access, OU=Private Internet Access, CN=Private Internet Access, name=Private Internet Access, emailAddress=secure@privateinternetaccess.com
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: VERIFY KU OK
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: NOTE: --mute triggered...
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: 5 variation(s) on previous 3 message(s) suppressed by --mute
May 30 16:38:10 Linksys EA8500 daemon.notice openvpn[2202]: [697a2631d36dca8eff022955d655caa6] Peer Connection Initiated with [AF_INET]91.108.183.74:1198
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: SENT CONTROL [697a2631d36dca8eff022955d655caa6]: 'PUSH_REQUEST' (status=1)
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: AUTH: Received control message: AUTH_FAILED
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: /tmp/openvpncl/route-down.sh tun1 1500 1622 10.41.10.6 10.41.10.5 init
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: Closing TUN/TAP interface
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: /sbin/ifconfig tun1 0.0.0.0
May 30 16:38:12 Linksys EA8500 daemon.notice openvpn[2202]: SIGTERM[soft,auth-failure] received, process exiting


I am now officially out of ideas. I think I will post a new subject in the "Advanced Networking" subforum, to get more eyes on it.


I "solved" the problem by moving to IPVanish.. I've gone for days, connections stayed live and haven't had a problem.

PIA had no solutions that helped the issue at all.

_________________
Routers:
Netgear R8000 - DD-WRT v3.0-r43420 std (06/15/20)
Netgear R9000 - DD-WRT v3.0-r43420 std (06/15/20)


Useful links:

Builds:
ftp://ftp.dd-wrt.com/betas/2020/


dd-wrt supported devices:
http://www.dd-wrt.com/wiki/index.php/Supported_Devices

So long <kong> and thanks for all the fish!
one_rob
DD-WRT Novice


Joined: 21 Aug 2017
Posts: 1

PostPosted: Mon Aug 21, 2017 1:53    Post subject: Reply with quote
I also had the problem of my R7000 disconnecting from the VPN (Private Internet Access), and not reconnecting. It would happen every 24 hours or so. Reading other forum topics, I did manage to set it up to automatically reconnect, and has been working for 4 or 5 days now.

Firstly, thanks to Mike42Smith in the following thread for pointing me in the right direction:
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=1044736

To get the VPN to automatically reconnect, I first had to create a script which stopped and restarted the OpenVPN service. This script needs to be created when the router first starts.
I had to use Telnet to create the script: whenever I tried creating the script through the web interface the script name would have a question mark at the end (even when I logged in from a Linux box). I expect it has something to do with CRLF.

Step 1: Create script

1. Using Telnet (Putty on PC) log on to the router.
2. run the following command:

Code:
nvram set rc_startup="
mkdir /tmp/openvpn
echo '#!/bin/sh
stopservice openvpn
sleep 30
startservice openvpn
' > /tmp/openvpn/fw-down.sh
chmod u+x /tmp/openvpn/fw-down.sh
chmod go-rwx /tmp/openvpn/fw-down.sh

/tmp/openvpn/fw-down.sh
"


This script creates the OpenVPN directory, puts a script in it, and then runs the script at startup. The script stops the VPN, waits 30 seconds, then starts it again.

After running command, commit it to the nvram with this command:
Code:
nvram commit


Reboot the router. Ensure that the script shows in the GUI (but don't modify it). Log on to router through telnet. Check the /tmp/openvpn directory, ensure the script exists.

Step 2: Tell OpenVPN to run the script when the VPN is goes down

This just requires you to add the two commands to the additional config section in the OpenVPN:
Code:
script-security 2
down /tmp/openvpn/fw-down.sh


For reference, my complete additional config section is:
Code:
sndbuf 524288
rcvbuf 524288
reneg-sec 0
keepalive 10 120
remote-cert-tls server
disable-occ
script-security 2
down /tmp/openvpn/fw-down.sh


That's all there is to it.
I recognise this isn't the most elegant solution, and think it could be better. For example checking to ensure the Internet is up, not waiting 30 seconds, etc. It also isn't necessary to create the openvpn directory under tmp. But it works for me (plus I'm somewhat new to dd-wrt). I might tweak it in the future if I find it necessary. This topic has some good ideas:
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=1078188
ramboboujee
DD-WRT Novice


Joined: 02 Apr 2020
Posts: 3

PostPosted: Thu Apr 02, 2020 18:21    Post subject: Reply with quote
one_rob wrote:
I also had the problem of my R7000 disconnecting from the VPN (Private Internet Access), and not reconnecting. It would happen every 24 hours or so. Reading other forum topics, I did manage to set it up to automatically reconnect, and has been working for 4 or 5 days now.

Firstly, thanks to Mike42Smith in the following thread for pointing me in the right direction:
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=1044736

To get the VPN to automatically reconnect, I first had to create a script which stopped and restarted the OpenVPN service. This script needs to be created when the router first starts.
I had to use Telnet to create the script: whenever I tried creating the script through the web interface the script name would have a question mark at the end (even when I logged in from a Linux box). I expect it has something to do with CRLF.

Step 1: Create script

1. Using Telnet (Putty on PC) log on to the router.
2. run the following command:

Code:
nvram set rc_startup="
mkdir /tmp/openvpn
echo '#!/bin/sh
stopservice openvpn
sleep 30
startservice openvpn
' > /tmp/openvpn/fw-down.sh
chmod u+x /tmp/openvpn/fw-down.sh
chmod go-rwx /tmp/openvpn/fw-down.sh

/tmp/openvpn/fw-down.sh
"


This script creates the OpenVPN directory, puts a script in it, and then runs the script at startup. The script stops the VPN, waits 30 seconds, then starts it again.

After running command, commit it to the nvram with this command:
Code:
nvram commit


Reboot the router. Ensure that the script shows in the GUI (but don't modify it). Log on to router through telnet. Check the /tmp/openvpn directory, ensure the script exists.

Step 2: Tell OpenVPN to run the script when the VPN is goes down

This just requires you to add the two commands to the additional config section in the OpenVPN:
Code:
script-security 2
down /tmp/openvpn/fw-down.sh


For reference, my complete additional config section is:
Code:
sndbuf 524288
rcvbuf 524288
reneg-sec 0
keepalive 10 120
remote-cert-tls server
disable-occ
script-security 2
down /tmp/openvpn/fw-down.sh


That's all there is to it.
I recognise this isn't the most elegant solution, and think it could be better. For example checking to ensure the Internet is up, not waiting 30 seconds, etc. It also isn't necessary to create the openvpn directory under tmp. But it works for me (plus I'm somewhat new to dd-wrt). I might tweak it in the future if I find it necessary. This topic has some good ideas:
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=1078188


Wow! This actually worked! Sorry for the old bump but I had to show my appreciation.

Thanks for posting this. Smile
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12881
Location: Netherlands

PostPosted: Thu Apr 02, 2020 20:35    Post subject: Reply with quote
This only works if the VPN is going down gracefully, if it just hangs the script will not execute in that case you can use a watchdog script.

See the fourth post in this thread:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=321686

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
ramboboujee
DD-WRT Novice


Joined: 02 Apr 2020
Posts: 3

PostPosted: Fri Apr 03, 2020 20:31    Post subject: Reply with quote
egc wrote:
This only works if the VPN is going down gracefully, if it just hangs the script will not execute in that case you can use a watchdog script.

See the fourth post in this thread:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=321686


Unfortunately, that fix did not work for my R8000.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12881
Location: Netherlands

PostPosted: Fri Apr 03, 2020 20:37    Post subject: Reply with quote
Are you running an older build?
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Goto page Previous  1, 2 Display posts from previous:    Page 2 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum