DD-WRT OpenVPN - Auto reconnect

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
jpny
OpenVpn Newbie
Posts: 5
Joined: Wed Aug 02, 2017 1:32 pm

DD-WRT OpenVPN - Auto reconnect

Post by jpny » Wed Aug 02, 2017 2:38 pm

Im been using OpenVPN on my DD-WRT router for a few days now and the connection has remained stable. Im using policy based routing to only route specific IPs over the VPN (https://charleswilkinson.co.uk/2016/05/14/selective-routing-using-ddwrt-and-openvpn). This morning I noticed that my VPN connection was closed (the VPN status page of the router also showed state - client (blank) and the log was completely empty).

A simple reboot fixed the connection, but I am looking for a way to automate the re-connect. I don't think I can use the routers built in watch dog as I think it monitors the "main" connection not the PBR VPN connection.

as per the VPN companies setup instructions my config file has the following

Code: Select all

remote-cert-tls server
remote-random
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
ping-timer-rem
reneg-sec 0
I think I can probably modify the ping-timer-rem command, or add one of the other ping commands, but I'm not really sure which one.

Can someone help me with this?
Also, any idea on how to test for the problem described above (unplugging just the modem doesn't simulate the problem, the router shows state - Client: RECONNECTING init_instance and when the modem come back online the VPN does re-establish itself)

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by TinCanTech » Wed Aug 02, 2017 3:43 pm

jpny wrote:as per the VPN companies setup instructions
The company that runs the server can disconnect you and close your openvpn remotely.

If they do so (and it sounds like they are), there is no option in openvpn to over ride this.

jpny
OpenVpn Newbie
Posts: 5
Joined: Wed Aug 02, 2017 1:32 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by jpny » Wed Aug 02, 2017 3:52 pm

is there no way to test if connection is closed and reboot?
or to have ping sent every x hours to keep alive?

jpny
OpenVpn Newbie
Posts: 5
Joined: Wed Aug 02, 2017 1:32 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by jpny » Thu Aug 03, 2017 11:31 am

I don't think it is the VPN company. in the past I have been connected for days at time, this morning I was disconnected when I woke up again and the router was rebooted just 7 hours ago.

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by TinCanTech » Thu Aug 03, 2017 6:01 pm

jpny wrote:I don't think it is the VPN company
Your logs will offer information ..

OpenVPN cannot spawn itself so your DD-WRT OS will have to monitor it.

jpny
OpenVpn Newbie
Posts: 5
Joined: Wed Aug 02, 2017 1:32 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by jpny » Thu Aug 03, 2017 9:18 pm

thanks. I just enabled the telnet log. the GUI log is empty after the disconnect. let me see what happens on the next disco

magellantx
OpenVpn Newbie
Posts: 1
Joined: Fri Sep 18, 2020 3:20 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by magellantx » Fri Sep 18, 2020 3:28 pm

I know this thread is few years old but I have the same issue and was wondering if there was a solution.

Whenever the underlying network gets interrupted (which happens frequently) the VPN will drop and the router always comes back with 'RECONNECTING init_instance' and It'll stay that way until I reboot it.

Rebooting has become a daily ritual and with 3 routers, it's a bit of a hassle so I'm hoping there's an easy way to either monitor the tunnel or otherwise detect when VPN has gone down and reboot the router automatically.

Here are the settings my provider gave me:

persist-key
persist-tun
fragment 1300
mssfix 1450
keysize 256

Thank you!!

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by TinCanTech » Fri Sep 18, 2020 4:19 pm

magellantx wrote:
Fri Sep 18, 2020 3:28 pm
Rebooting has become a daily ritual and with 3 routers, it's a bit of a hassle so I'm hoping there's an easy way to either monitor the tunnel or otherwise detect when VPN has gone down and reboot the router automatically
There is .. get a better router.

300000
OpenVPN Expert
Posts: 685
Joined: Tue May 01, 2012 9:30 pm

Re: DD-WRT OpenVPN - Auto reconnect

Post by 300000 » Wed Nov 11, 2020 5:19 pm

you can add this on your dd wrt config . it will restart connect auto for you .

remap-usr1 SIGHUP
keepalive 90 190
ping 90

three of them will keep your ddwrt happy to connect . i am using openvpn ddwrt router over 10 years so get used to with that trouble so many times

Lagosazules
OpenVpn Newbie
Posts: 1
Joined: Thu Jan 21, 2021 8:04 am

Re: DD-WRT OpenVPN - Auto reconnect

Post by Lagosazules » Thu Jan 21, 2021 8:30 am

Same story, using NordVPN and I think I use a good router linksys wrt1900acs with ddwrt, so I think that is not the problem
Im using also policy based routing to only route specific IPs over the VPN
My nordvpn config file also is:

remote-cert-tls server
remote-random
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
ping-timer-rem
reneg-sec 0

When I add the following lines the VPN stops working

remap-usr1 SIGHUP
keepalive 90 190
ping 90

Any suggestions to fix this? Thanks

To add a kill switch working on ath1,1 with policy based routing I already found a solution on:

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=317397

FurryPixie
OpenVpn Newbie
Posts: 1
Joined: Wed Jul 07, 2021 11:35 am

Re: DD-WRT OpenVPN - Auto reconnect

Post by FurryPixie » Wed Jul 07, 2021 11:36 am

Lagosazules wrote:
Thu Jan 21, 2021 8:30 am
Same story, using NordVPN and I think I use a good router linksys wrt1900acs with ddwrt, so I think that is not the problem
Im using also policy based routing to only route specific IPs over the VPN
My nordvpn config file also is:

remote-cert-tls server
remote-random
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
ping-timer-rem
reneg-sec 0 greatpeople.me

When I add the following lines the VPN stops working

remap-usr1 SIGHUP
keepalive 90 190
ping 90

Any suggestions to fix this? Thanks

To add a kill switch working on ath1,1 with policy based routing I already found a solution on:

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=317397
I have been connected for days at time, this morning I was disconnected when I woke up again and the router was rebooted just 7 hours ago.

Post Reply