Is there a command line to automaticly reconnect the VPN on a timer

Xentrk

Part of the Furniture
Alternatively, there is the stop and start syntax available:

service stop_vpnclient1
service start_vpnclient1

Code:
cru

Cron Utility
add:    cru a <unique id> <"min hour day month week command">
delete: cru d <unique id>
list:   cru l
Code:
cru a VPN_START "0 2 * * * service stop_vpnclient1 #Stop VPN at 2 AM
cru a VPN_STOP "0 13 * * * service start_vpnclient1 #Start VPN at 1 PM
 

datan

New Around Here
for reference, here's the script that I use to check whether the VPN tunnel is up (by pinging google.com). If not, reset it.


#/bin/sh

ping -c 1 -w 3 -I tun11 google.com

if [ $? -eq 0 ]; then
date +"%Y-%m-%d %r - UP" >> /dev/null
else
date +"%Y-%m-%d %r - DOWN" >> /jffs/scripts/check.log
service restart_vpnclient1
fi
 

Butterfly Bones

Very Senior Member
for reference, here's the script that I use to check whether the VPN tunnel is up (by pinging google.com). If not, reset it.


#/bin/sh

ping -c 1 -w 3 -I tun11 google.com

if [ $? -eq 0 ]; then
date +"%Y-%m-%d %r - UP" >> /dev/null
else
date +"%Y-%m-%d %r - DOWN" >> /jffs/scripts/check.log
service restart_vpnclient1
fi
Do you run that from a cron job or a /jffs/scripts/<some startup script> ?
 

Butterfly Bones

Very Senior Member
That is what I did.

To help others, here is a detailed setup.
Use the script from @datan above. I placed it in /jffs/scripts as "vpncheck.sh"
Code:
#/bin/sh

ping -c 1 -w 3 -I tun11 google.com

if [ $? -eq 0 ]; then
date +"%Y-%m-%d %r - UP" >> /dev/null
else
date +"%Y-%m-%d %r - DOWN" >> /jffs/scripts/check.log
service restart_vpnclient1
fi
Remember it needs full permissions using chmod 755
Code:
chmod 755 /jffs/scripts/vpncheck.sh
Add this to /jffs/scripts/services-start.
(The "*/5" means it checks every 5 minutes, adjust for your preferences.)
Code:
cru a CheckVPNTunnel "*/5 * * * * /jffs/scripts/vpncheck.sh"
To manually start it without running /jffs/scripts/services-start Use this on the command line
Code:
cru a CheckVPNTunnel "*/5 * * * * /jffs/scripts/vpncheck.sh"
After that it will be set to run after every router reboot.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top