Lars Hjortshøj Andersen
New Around Here
Is there a command line in the custom vpn confirguration to automaticly disconnect and reconnect the VPN on a timer?
for exsample twice a day?
for exsample twice a day?
cru
Cron Utility
add: cru a <unique id> <"min hour day month week command">
delete: cru d <unique id>
list: cru l
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
Do you run that from a cron job or a /jffs/scripts/<some startup script> ?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
#/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
chmod 755 /jffs/scripts/vpncheck.sh
cru a CheckVPNTunnel "*/5 * * * * /jffs/scripts/vpncheck.sh"
cru a CheckVPNTunnel "*/5 * * * * /jffs/scripts/vpncheck.sh"
Oct 12 10:00:09 RT-AC86U-4608 ovpn-client1[7415]: Initialization Sequence Completed
Oct 22 09:25:12 RT-AC86U-4608 ovpn-client1[7415]: event_wait : Interrupted system call (code=4)
Oct 22 09:25:12 RT-AC86U-4608 ovpn-client1[7415]: vpnrouting.sh tun11 1500 1552 10.200.0.82 10.200.0.81 init
Oct 22 09:25:12 RT-AC86U-4608 ovpn-client1[7415]: Closing TUN/TAP interface
Oct 22 09:25:12 RT-AC86U-4608 ovpn-client1[7415]: /sbin/ifconfig tun11 0.0.0.0
Oct 22 09:25:12 RT-AC86U-4608 ovpn-client1[7415]: updown.sh tun11 1500 1552 10.200.0.82 10.200.0.81 init
Oct 22 09:25:12 RT-AC86U-4608 ovpn-client1[7415]: SIGTERM[hard,] received, process exiting
Oct 22 09:25:13 RT-AC86U-4608 ovpn-client1[21469]: OpenVPN 2.4.9 arm-buildroot-linux-gnueabi [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Apr 25 2020
Oct 22 09:25:13 RT-AC86U-4608 ovpn-client1[21469]: library versions: OpenSSL 1.1.1g 21 Apr 2020, LZO 2.08
Oct 22 09:25:13 RT-AC86U-4608 ovpn-client1[21470]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Oct 22 09:25:14 RT-AC86U-4608 ovpn-client1[21470]: TCP/UDP: Preserving recently used remote address: [AF_INET]xxx.58.130.yyy:pppp
( %< snip )
Oct 22 09:25:20 RT-AC86U-4608 ovpn-client1[21470]: TUN/TAP device tun11 opened
Oct 22 09:25:20 RT-AC86U-4608 ovpn-client1[21470]: TUN/TAP TX queue length set to 1000
Oct 22 09:25:20 RT-AC86U-4608 ovpn-client1[21470]: /sbin/ifconfig tun11 10.200.0.14 pointopoint 10.200.0.13 mtu 1500
Oct 22 09:25:20 RT-AC86U-4608 ovpn-client1[21470]: updown.sh tun11 1500 1552 10.200.0.14 10.200.0.13 init
Oct 22 09:25:22 RT-AC86U-4608 ovpn-client1[21470]: Initialization Sequence Completed
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!