OpenVPN reconnects only after reboot router

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
wellitsme
DD-WRT Novice


Joined: 30 Jan 2022
Posts: 6

PostPosted: Thu Feb 03, 2022 16:22    Post subject: OpenVPN reconnects only after reboot router Reply with quote
Hello everyone,

so i have a Linksys 3200acm Firmware: DD-WRT v3.0-r48141 std (01/21/22) everything works fine now but when OpenVPN gets disconnected it doesnt automatically reconnect. I than have to reboot my linksys router manually to reconnect. I am forwarding my traffic to ISP router. I have a static routing on ISP router to subnet of my Linksys VPN router and static IP on WAN port on Linksys.

these are the commands i have so far.

iptables -I FORWARD -s 192.168.1.0/24 -j ACCEPT
WAN_IF="$(ip route | awk '/^default/{print $NF}')"
iptables -I FORWARD -i br0 -o $WAN_IF -j REJECT

is there a command that can reboot router after 5 min of no successful connection to VPN? or any other method i can implement to not have to reboot router manually every time OpenVPN gets disconnected?
Sponsor
bushant
DD-WRT Guru


Joined: 18 Nov 2015
Posts: 2174

PostPosted: Thu Feb 03, 2022 16:52    Post subject: Reply with quote
VPN watchdog scripts

By egc:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1179379#1179379

By eibgrad:
https://pastebin.com/iNC273ER

An old one by @sploit, no idea if it still works:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1093571#1093571

Or from command line, telnet/SSH:
stopping and starting OpenVPN client:
While the client is running:
stopservice openvpn
startservice openvpn

_________________
Forum Guide Lines (with helpful pointers about how to research your router, where and what firmware to download, where and how to post and many other helpful tips!)
How to get help the right way

Before asking for help - Read the forum guidelines AND Upgrade DD-WRT!
wellitsme
DD-WRT Novice


Joined: 30 Jan 2022
Posts: 6

PostPosted: Fri Feb 04, 2022 5:03    Post subject: Reply with quote
bushant wrote:
VPN watchdog scripts

By egc:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1179379#1179379

By eibgrad:
https://pastebin.com/iNC273ER

An old one by @sploit, no idea if it still works:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1093571#1093571

Or from command line, telnet/SSH:
stopping and starting OpenVPN client:
While the client is running:
stopservice openvpn
startservice openvpn


THX alot for these scripts!
I got watchdog up and working. Great help Thx alot alot!!!
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 13650
Location: Netherlands

PostPosted: Fri Feb 04, 2022 7:18    Post subject: Reply with quote
In the OpenVPN client setup guide are some tips to mitigate disconnections but often that is not enough and running a watchdog script is then the next step Sad

@eibgrad and I are currently working to incorporate a watchdog in DDWRT as it is a fairly common problem with numerous providers (see picture).

In the mean time use one of the scripts @bushant already pointed to Smile



Naamloos.png
 Description:
 Filesize:  9.56 KB
 Viewed:  293 Time(s)

Naamloos.png



_________________
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
bushant
DD-WRT Guru


Joined: 18 Nov 2015
Posts: 2174

PostPosted: Fri Feb 04, 2022 13:54    Post subject: Reply with quote
egc wrote:
In the OpenVPN client setup guide are some tips to mitigate disconnections


I looked through the guide before I replied to @wellitsme to see if the watchdog was there and completely overlooked this section Embarassed

I have never experienced connection problems or drops but I started using a watchdog a while back anyway.

GUI method will be easier I guess so thanks to you two for the upcoming improvement!
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 13650
Location: Netherlands

PostPosted: Fri Feb 04, 2022 14:03    Post subject: Reply with quote
Yeah I personally also have no connection problems, it seems dependant on provider and also on used servers, some are more busy than others.

But it is not a big problem to add it to the GUI.

Also on the Server side there will be a GUI option to NAT incoming VPN traffic for easier access to LAN clients on the servers subnet.
(Although I prefer to tweak the firewall of the Local LAN clients which you want to have access so that the VPN clients do not have access to everything which is the downside of that rule)

_________________
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
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6868
Location: UK, London, just across the river..

PostPosted: Fri Feb 04, 2022 14:20    Post subject: Reply with quote
i guess if you ping 9.9.9.9 that frequently they may put you in a block list... Cool Embarassed

but yep watchdog via GUI is an useful extra..
to be honest i ve 30+ days using the same VPN server and never had a drop, so apart of local client config is to a VPN provider too, i guess.. Rolling Eyes

those advanced OpenVPN commands help too
reneg-sec 0
keepalive 10 120
server-poll-timeout 10
remote servername or ip port

on the last command you have to add your server details and port...
you can use the GUI option for multiple preferred servers for that now, thanks to egc...

p.s. edited: set reneg-sec 14400 ,as with 14400 it helps to keep alive, I don't use 0 anyway..

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 58184 WAP
TP-Link WR1043NDv2 -DD-WRT 61745 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 61745 Gateway/DoT,Forced DNS,AP Isolation,2VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 61745 Gateway/DNSCryptv2,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 61711 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Dynalink DL-WRX36-DDWRT 61745
Broadcom
Netgear R7000 --DD-WRT 61745 Gateway/DNScrypt-proxy2/AD-Block,IPset Firewall,Forced DNS,x4VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913


Last edited by Alozaros on Sat Feb 05, 2022 1:01; edited 2 times in total
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 13650
Location: Netherlands

PostPosted: Fri Feb 04, 2022 14:28    Post subject: Reply with quote
Default value is 30 but I have been using it for 24 hour with ping interval 10 without a problem Smile

reneg-sec 0 is a small security risk, for average users no problem but if you are a high level government target or live in a non free country better not use it

_________________
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
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9357

PostPosted: Fri Feb 04, 2022 20:09    Post subject: Reply with quote
Alozaros wrote:
i guess if you ping 9.9.9.9 that frequently they may put you in a block list...


This is one reason I think we need to consider updating the GUI to accept a domain name in many locations and NOT just an explicit IP.

If that was the case, then you could add something like the following to DNSMasq.

Code:
host-record=ping-host,ping-host.mylan,8.8.8.8
host-record=ping-host,ping-host.mylan,4.2.2.1
host-record=ping-host,ping-host.mylan,209.244.0.3
host-record=ping-host,ping-host.mylan,8.8.4.4
host-record=ping-host,ping-host.mylan,4.2.2.3
host-record=ping-host,ping-host.mylan,1.0.0.1
host-record=ping-host,ping-host.mylan,9.9.9.9
host-record=ping-host,ping-host.mylan,4.2.2.6
host-record=ping-host,ping-host.mylan,208.67.222.222
host-record=ping-host,ping-host.mylan,4.2.2.2
host-record=ping-host,ping-host.mylan,209.244.0.4
host-record=ping-host,ping-host.mylan,1.1.1.1
host-record=ping-host,ping-host.mylan,4.2.2.4
host-record=ping-host,ping-host.mylan,208.67.220.220
host-record=ping-host,ping-host.mylan,4.2.2.5


What this does is create a DNS record where with each reference it returns the next IP in the list, so you don't just keep accessing the same IP and risk being banned. I've purposely scrambled it so it's more unlikely you'd access the same provider in sequence (e.g., 8.8.8.8, then 8.8.4.4).

It's NOT that I've had an issue w/ being banned, but it has been something I'm aware of as a possibility, and so preemptively I've implemented the above whenever and wherever feasible to minimize that risk.

And in cases where a given provider might be down, you don't want to be dependent on a single source for determining a communications failure. It might NOT be YOU, but THEM!

_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
jjwatmyself
DD-WRT User


Joined: 19 Mar 2016
Posts: 55

PostPosted: Sat Feb 05, 2022 18:16    Post subject: Reply with quote
I have found that pinging something on the other end of the tunnel is more accurate for sensing issues on the tunnel. And detect Internet issues independently of VPN issues.

My script is here. Feel free to incorporate any elements that would be helpful into the GUI OpenVPN Watchdog @egc and @eibgrad

https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1256142#1256142

_________________
--------------------------------------------------
VLANs, port trunking, virtual SSID (Guest)
DNSmasq, NTP, syslog, nflow
Hub and spoke, multi-site, routed VPN (OpenVPN client), split tunnel
1 DNS zone per site, forward, reverse look-up across all sites

Asus RT-AC68U rev A2 DD-WRT v3.0-r48138 std (01/17/22)
Asus RT-AC68U rev C1 DD-WRT v3.0-r48138 std (01/17/22)
Asus RT-AC1900P DD-WRT v3.0-r48138 std (01/17/22)
Asus RT-AC1900P DD-WRT v3.0-r48138 std (01/17/22)
Netgear R7000 DD-WRT v3.0-r48138 std (01/17/22)
Linksys E2000 DD-WRT v3.0-r33492 mega (10/10/17)
johnnyNobody999
DD-WRT Guru


Joined: 10 Jan 2014
Posts: 587

PostPosted: Fri May 02, 2025 0:43    Post subject: Reply with quote
eibgrad wrote:
This is one reason I think we need to consider updating the GUI to accept a domain name in many locations and NOT just an explicit IP.

If that was the case, then you could add something like the following to DNSMasq.

Code:
host-record=ping-host,ping-host.mylan,8.8.8.8
host-record=ping-host,ping-host.mylan,4.2.2.1
.
.
host-record=ping-host,ping-host.mylan,4.2.2.4


What this does is create a DNS record where with each reference it returns the next IP in the list, so you don't just keep accessing the same IP and risk being banned. I've purposely scrambled it so it's more unlikely you'd access the same provider in sequence (e.g., 8.8.8.8, then 8.8.4.4).


I was considering using this for the wireguard watchdog. I came across some other info that recommended using address=/myhost/8.8.8.8, address=/myhost/4.2.2.1, etc, instead which seems to operate the same way. I don't know which code is "better". I did have a question about this, does adding all this to dnsmasq require any other settings to achieve a "round-robin" effect or random selection of "myhost"? Running <ping myhost> from the router CLI seems to select the same server after executing the command 10 times. So, do I need to do something else? By the way, some of the addresses in your code did not get a ping reply so I edited them out.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking 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 cannot attach files in this forum
You cannot download files in this forum