Viktor Jaep
Part of the Furniture
v1.2 - Now with even more SuperRandom(tm) goodness!!
Updated May 02, 2022
Executive Summary: VPNON 1.2 (VPNON.SH) is an all-in-one script which compliments @JackYaz's VPNMGR program to maintain a NordVPN/PIA/WeVPN setup, though this is not a requirement, and can function without problems in a standalone environment using the options/parameters below. VPNON is meant to be run with a CRU job in order to reset and randomly connect to a new VPN server each day, or multiple times a day/week, at a different location specified within VPNMGR through NordVPN/PIA/WeVPN. It also optionally downloads a list of US-based NordVPN server IP addresses, and optionally adds them to the Skynet whitelist each time this runs, as these frequently change. Set the variable below to enable/disable this functionality. Logging has been added to capture relevant events for later review.
VPNON is free to use under the GNU General Public License version 3 (GPL 3.0).
This project is hosted on GitHub
Changelog here / What's new: YazFi Integration + Multi-Country support
Updated May 02, 2022
Executive Summary: VPNON 1.2 (VPNON.SH) is an all-in-one script which compliments @JackYaz's VPNMGR program to maintain a NordVPN/PIA/WeVPN setup, though this is not a requirement, and can function without problems in a standalone environment using the options/parameters below. VPNON is meant to be run with a CRU job in order to reset and randomly connect to a new VPN server each day, or multiple times a day/week, at a different location specified within VPNMGR through NordVPN/PIA/WeVPN. It also optionally downloads a list of US-based NordVPN server IP addresses, and optionally adds them to the Skynet whitelist each time this runs, as these frequently change. Set the variable below to enable/disable this functionality. Logging has been added to capture relevant events for later review.
VPNON is free to use under the GNU General Public License version 3 (GPL 3.0).
This project is hosted on GitHub
Changelog here / What's new: YazFi Integration + Multi-Country support
The Problem I was trying to solve
- As a VPNMGR user, I had 5 different NordVPN VPN Client configurations populated on my Asus router running Merlin FW, each with a different city. I wanted a way for my VPN connection to reset each night, so that it would randomly select and connect to a different configuration, thus endpoint, so that I wouldn't be connected to the same city 24x7x365.
- NordVPN has thousands of VPN endpoint servers which change frequently, depending on the distance or latency from your location scattered across the globe. On several occations, my Asus-Merlin-based Skynet firewall would block these VPN servers, and wanted to make sure I had a way to find all the latest VPN server IPs, and add them to the Skynet whitelist.
- Above all, I wanted to make this script flexible enough for those who aren't running VPNMGR, using NordVPN or making use of the Skynet Firewall, so options have been built-in to bypass this functionality to make it usable in any VPN usage scenario.
How is this script supposed to run?
Personally, I run this script 1x a day at night using a CRU job. But you can run it as much as you want... read up on CRU formatting. Secondarily, this script is also integrated directly into my other program, VPNMON-R2, and runs when it detects that the VPN connection has dropped. Here are some instructions and steps to make a nightly job happen:- Download and install from your favorite SSH tool, copy & paste this command:
Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNON/master/vpnon-1.2.sh" -o "/jffs/scripts/vpnon.sh" && chmod a+rx "/jffs/scripts/vpnon.sh"
- To initially configure this script, open up a dedicated SSH window, and simply execute the script:
Code:
sh /jffs/scripts/vpnon-r2.sh -config
- Once you've successfully configured the various options, you can run the script using this command:
Code:
sh /jffs/scripts/vpnon-r2.sh -reset
- To run this script every night at 01:00 (for instance), from a command prompt, enter:
Code:
cru a vpnon "00 01 * * * /jffs/scripts/vpnon.sh -reset"
- To ensure that this job is added each time after you reboot your router, make sure you add this cru statement above to your "services-start" file.
What this script does
- Kills all VPN Clients, if they're running or not
- Updates Skynet whitelist with all US-based NordVPN endpoint IP addresses (optional) - FYI, you can easily change this for the country of your choice.
- Updates VPNMGR cache with recommended NordVPN/PIA/WeVPN endpoint information (optional), and merges/refreshes these changes with your Merlin VPN Client configurations
- Uses a randomizer to pick one of 5 different VPN Clients to connect to (configurable between 1 and 5)
- Initiates the connection to the specified VPN endpoint.
- Logs major events (resets/connection errors/etc) to /jffs/scripts/vpnmon-r2.log (optional)
- Added a new API lookup to display the VPN exit node city/location on screen and in the logs. This API is free, and guarantees at least 1000 lookups per month. In lieu of doing a lookup each single refresh interval, a location lookup is only done when VPNON is doing a reset.
- Added the concept of SuperRandom(tm) NordVPN Connections! This is a NordVPN feature only! When enabled (NordVPNSuperRandom=1), it will fill your VPN client slots with random VPN servers across the country of your choice (set by the NordVPNCountry variable). Distance, load, and performance be damned!!
- Added an integrated configuration utility (by running "vpnon.sh -config") that steps you through all the options and saves results to a config file, without the need to manually edit and configure the script itself.
- Added a script update checker, which notifies you when a new version becomes available while the script is running and within the logs, and allows you to easily download an install the latest script by using the 'vpnon.sh -update' command.
- Added the ability to specify up to 2 additional NordVPN countries (for a total of 3) to randomly pick VPN servers located within that country. Yes, we have gone completely international!
- Happy to report that VPNON now integrates beautifully with YazFi - the premier expanded guest network utility for Merlin firmware! For those running multiple guest networks, VPNON can now automatically update your guest network slots with the latest VPN slot that VPNON just made a connection to, then performs the necessary steps to make YazFi acknowledge the change to ensure your guest client devices continue to work without interruption!
What if I'm not running VPNMGR/NordVPN(PIA/WeVPN)/Skynet?
- As long as your VPN slots are configured and tested using the VPN provider of your choice, this script will run perfectly fine, and can monitor, reset and randomly start a new VPN client slot for you each day. Please know, this script was written to compliment VPNMGR, and gives a heavy preference to NordVPN, but neither is required.
- While stepping through the configuration utility ("vpnon.sh -config"), you can choose to disable the ability to update VPNMGR hosts, enable/disable specific NordVPN functionality, and the ability to whitelist the latest NordVPN servers in Skynet.
- Let me know how you're using this script! Feel free to post in these forums.
Usage
- VPNON is driven with commandline parameters. These are the available options:
- vpnon.sh -h (or vpnon.sh -help) -- displays a short overview of available commands
- vpnon.sh -log -- displays the contents of the VPNON activity log in the NANO text editor
- vpnon.sh -config -- launches the configuration utility and saves your settings to a local config file
- vpnon.sh -update -- launches the script update utility to download the newest version
- vpnon.sh -reset -- runs the familiar VPN reset and randomize functionality
Gotchas
- If you want to make the integration with VPNMGR, please make sure you have installed VPNMGR, have populated your VPN slots with it, have tested refreshing its cache, and that you are able to successfully connect to NordVPN before running this script. You may find the program and installation/configuration information here: https://www.snbforums.com/threads/v...ent-configurations-for-nordvpn-and-pia.64930/
- If you don't want to integrate with VPNMGR, or whitelist NordVPN IPs in your Skynet Firewall, etc... please choose to disable this functionality in the configuration utility ("vpnon.sh -config")
- Make sure you keep your VPN Client slots sequential... don't use 1, 2, and 4... for instance. Keep it to 1, 2, and 3.
- If you're using the SuperRandom(tm) functionality, please be sure that each of your VPN slots are fully configured, as this function will only replace your "server address" IP and the "description" in NordVPN - [CITY] format. It is also important to disable the VPNMGR update so they don't conflict.
Last edited: