Viktor Jaep
Part of the Furniture
VPNMON-R3 v1.3.8
Updated November 28, 2024
Executive Summary: VPNMON-R3 (vpnmon-r3.sh) is an all-in-one script that is optimized to maintain multiple OpenVPN connections and is able to provide for the capabilities to randomly reconnect using a specified server list containing the servers of your choice. Special care has been taken to ensure that only the VPN connections you want to have monitored are tended to. This script will check the health of up to 5 VPN connections on a regular interval to see if monitored VPN connections are connected, and sends a ping to a host of your choice through each active connection. If it finds that a connection has been lost, it will execute a series of commands that will kill that single VPN client, and randomly picks one of your specified servers to reconnect to for each VPN client. It also monitors your WAN/Dual-WAN connection and drops back until your WAN connection comes back up to reconnect your VPN tunnels.
VPNMON is free to use under the GNU General Public License version 3 (GPL 3.0).
This project is hosted on GitHub
Changelog [here] / Jump to [Latest Release Notes] / What's new: Bug fixes & Enhancements, AMTM Email Notifications, Skynet Whitelisting, Reset > Ping Value, WAN/Dual-WAN Monitoring, Pause on -RESET, Added Connected Time, Added PING stats, Added Unbound-over-VPN, Added Server List Automation, Initial Beta Release!
Examples & Tutorials -- further help on how to create custom CURL+JQ statements for your VPN Client Slot Server Lists available here
Screenshot:
Updated November 28, 2024
Executive Summary: VPNMON-R3 (vpnmon-r3.sh) is an all-in-one script that is optimized to maintain multiple OpenVPN connections and is able to provide for the capabilities to randomly reconnect using a specified server list containing the servers of your choice. Special care has been taken to ensure that only the VPN connections you want to have monitored are tended to. This script will check the health of up to 5 VPN connections on a regular interval to see if monitored VPN connections are connected, and sends a ping to a host of your choice through each active connection. If it finds that a connection has been lost, it will execute a series of commands that will kill that single VPN client, and randomly picks one of your specified servers to reconnect to for each VPN client. It also monitors your WAN/Dual-WAN connection and drops back until your WAN connection comes back up to reconnect your VPN tunnels.
VPNMON is free to use under the GNU General Public License version 3 (GPL 3.0).
This project is hosted on GitHub
Changelog [here] / Jump to [Latest Release Notes] / What's new: Bug fixes & Enhancements, AMTM Email Notifications, Skynet Whitelisting, Reset > Ping Value, WAN/Dual-WAN Monitoring, Pause on -RESET, Added Connected Time, Added PING stats, Added Unbound-over-VPN, Added Server List Automation, Initial Beta Release!
Examples & Tutorials -- further help on how to create custom CURL+JQ statements for your VPN Client Slot Server Lists available here
Screenshot:
Assumptions
- Functional VPN Environment -- You must already have a working VPN client environment. This means, your VPN client(s) must already be in working order using your current VPN provider. When you slide that VPN client switch to the "ON" position in your Merlin Firmware UI, your VPN client must be able to make a successful connection. Make sure each client works (up to 5) if you want these to be monitored by VPNMON-R3.
- VPN Director has been configured -- You must have allocated which devices you want to talk to which VPN connections using the VPN Director function within the Merlin Firmware.
- VPN Server IP List Creation -- In order to generate VPN server lists for your individual clients, you must be able to gather the IP addresses of the VPN servers from your VPN provider that you want each VPN client to make a connection with. These IP addresses need to be entered in (or copied into) each of the (up to) 5 server lists using the VPNMON-R3 "Update/Maintain VPN Server Lists" functionality as a single column of IPv4 addresses.
- Standard Configuration Basics -- As with practically running any custom script on your router, you must at least have an external USB drive installed, formatted with a swap file and with Entware enabled using AMTM. Last, you must also have enabled JFFS scripting through your Merlin Firmware UI.
Use-case
- You may be running multiple VPN connections dedicated to specific devices on your network (TV/Streaming, family devices, IoT devices, testing, etc.).
- You may be using multiple VPN providers, say NordVPN on one connection, and SurfShark on another.
- You may want control over which selection of VPN servers these VPN clients can reconnect to.
- You want a monitoring tool to ensure each of your monitored VPN connections remain healthy, and will initiate a reconnection if any ping or curl test fails across the tunnel, giving you peace of mind that your VPN environment will achieve maximum uptime.
How is this script supposed to run?
It is highly recommended to run this script from a SCREEN utility window running directly on the router itself, reachable through its own SSH window... but could very well just run from a PC that's connected directly to the Asus router, as it loops and checks the connection every 60 seconds. Instructions:- Download and install directly using your favorite SSH tools, copy & paste this command (or install directly from AMTM!):
Code:curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R3/main/vpnmon-r3.sh" -o "/jffs/scripts/vpnmon-r3.sh" && chmod 755 "/jffs/scripts/vpnmon-r3.sh"
- To initially configure this script, open up a dedicated SSH window, and simply execute the script:
Code:sh /jffs/scripts/vpnmon-r3.sh -setup
- Once you've successfully configured the various options, you can run the script using this command:
Code:sh /jffs/scripts/vpnmon-r3.sh
- To make life easier, can now also just launch or reconnect to VPNMON-R3 with the -screen switch to allow it run in the background without needing a dedicated SSH window connection. Type:
Code:vpnmon-r3 -screen
Last edited: