Martineau - I'm trying your VPN Failover script, thanks for providing, but I have a few questions.
1. I need to put an "sh " before running the status checking line, and to add a ".sh" to the script name. Here is the line that works:
sh ./VPN_Failover.sh status
Is this expected?
2. I changed the checking period to be 600 secs (5 min) rather than 3600 secs. Do you see a problem with that?
3. How can I check that the cron job and script is working?
4. I see that you have an email parameter in the command line. Can I use that to notify me of a disconnect and subsequent reconnect? Could you give an example line that I could modify and run? Also, rather than email, is it possible to send a txt message?
5. When I manually shut-down the VPN, the logs contain this info:
Aug 1 11:16:43 rc_service: httpds 826:notify_rc stop_vpnclient1
Aug 1 11:16:43 custom_script: Running /jffs/scripts/service-event (args: stop vpnclient1) - max timeout = 120s
Aug 1 11:16:43 ovpn-client1[13013]: event_wait : Interrupted system call (code=4)
Aug 1 11:16:43 ovpn-client1[13013]: vpnrouting.sh tun11 1500 1550 10.47.11.6 10.47.11.5 init
Aug 1 11:16:43 openvpn-routing: Configuring policy rules for client 1
Aug 1 11:16:43 custom_script: Running /jffs/scripts/openvpn-event (args: tun11 1500 1550 10.47.11.6 10.47.11.5 init)
Aug 1 11:16:43 openvpn-event[30702]: route-pre-down
Aug 1 11:16:43 ovpn-client1[13013]: ERROR: Linux route delete command failed: external program exited with error status: 2
Aug 1 11:16:43 ovpn-client1[13013]: ERROR: Linux route delete command failed: external program exited with error status: 2
Aug 1 11:16:43 ovpn-client1[13013]: ERROR: Linux route delete command failed: external program exited with error status: 2
Aug 1 11:16:43 ovpn-client1[13013]: Closing TUN/TAP interface
How can I fix those error messages?
Also, when I restart the VPN, this is what I see in the logs:
Aug 1 11:19:54 rc_service: httpds 826:notify_rc start_vpnclient1
Aug 1 11:19:54 custom_script: Running /jffs/scripts/service-event (args: start vpnclient1) - max timeout = 120s
Aug 1 11:19:54 ovpn-client1[30989]: OpenVPN 2.4.6 arm-buildroot-linux-gnueabi [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Dec 8 2018
Aug 1 11:19:54 ovpn-client1[30989]: library versions: OpenSSL 1.0.2q 20 Nov 2018, LZO 2.08
Aug 1 11:19:54 ovpn-client1[30990]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Aug 1 11:19:55 ovpn-client1[30990]: TCP/UDP: Preserving recently used remote address: [AF_INET]174.128.246.10:1198
Aug 1 11:19:55 ovpn-client1[30990]: UDP link local: (not bound)
Aug 1 11:19:55 ovpn-client1[30990]: UDP link remote: [AF_INET]174.128.246.10:1198
Aug 1 11:19:55 ovpn-client1[30990]: 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,
[email protected]
Aug 1 11:19:55 ovpn-client1[30990]: VERIFY KU OK
Aug 1 11:19:55 ovpn-client1[30990]: Validating certificate extended key usage
Aug 1 11:19:55 ovpn-client1[30990]: ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
Aug 1 11:19:55 ovpn-client1[30990]: VERIFY EKU OK
Aug 1 11:19:55 ovpn-client1[30990]: VERIFY OK: depth=0, C=US, ST=CA, L=LosAngeles, O=Private Internet Access, OU=Private Internet Access, CN=52fbf5a1ccf06c163862c61ccc2ea0, name=52fbf5a1ccf06c163862c61ccc2ea0
Aug 1 11:19:55 ovpn-client1[30990]: Control Channel: TLSv1.2, cipher TLSv1/SSLv3 DHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Aug 1 11:19:55 ovpn-client1[30990]: [52fbf5a1ccf06c163862c61ccc2ea0] Peer Connection Initiated with [AF_INET]174.128.246.10:1198
Aug 1 11:20:01 ovpn-client1[30990]: auth-token received, disabling auth-nocache for the authentication token
Aug 1 11:20:01 ovpn-client1[30990]: Outgoing Data Channel: Cipher 'AES-128-GCM' initialized with 128 bit key
Aug 1 11:20:01 ovpn-client1[30990]: Incoming Data Channel: Cipher 'AES-128-GCM' initialized with 128 bit key
Aug 1 11:20:01 ovpn-client1[30990]: TUN/TAP device tun11 opened
Aug 1 11:20:01 ovpn-client1[30990]: do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Aug 1 11:20:01 ovpn-client1[30990]: /bin/ip link set dev tun11 up mtu 1500
Aug 1 11:20:01 ovpn-client1[30990]: /bin/ip addr add dev tun11 local 10.4.10.6 peer 10.4.10.5
Aug 1 11:20:03 openvpn-routing: Configuring policy rules for client 1
Aug 1 11:20:03 custom_script: Running /jffs/scripts/openvpn-event (args: tun11 1500 1550 10.4.10.6 10.4.10.5)
Aug 1 11:20:03 openvpn-event[1555]: route-up
Aug 1 11:20:03 ovpn-client1[30990]: Initialization Sequence Completed
Does all that look OK to you?