Posted: Sat Jun 01, 2019 19:47 Post subject: NordVPN easy_script connection
Hi to all.
First of all I want to say that I'm not a professional programmer, so, maybe this little script is not perfect and can be improved, so if you find some that not work so good or you've a better idea method, you're welcome to tell me what is wrong!
So, this script basically:
1. For each country you select, search the top server and pick the best one!
2. Start a watchdog for vpn interface, that check every 60 sec if the vpn is up and running.
3. Start a watchdog for server load, if the current load is over a threshold, change it.
How install it?
Simply copy the script to your preferred place, I prefer copy it to /opt/bin and make it executable with chmod ugo+x /opt/bin/easy_nordvpn
How can I run the script?
I usually have one script that I call at boot, so I prefer use an intermediate script to do all the dirty works, and from the Administration -> Commands -> Startup I call it, so in my case inside the Startup field I've /opt/startup_script.sh and inside the startup_script.sh I've sleep 30 && /opt/bin/easy_nordvpn start
So at the end you've to put sleep 30 && /opt/bin/easy_nordvpn start in your startup
Now you've to configure your vpn client like always, go to Services -> VPN -> OpenVPN Client and configure the client like NordVPN suggest.
The very next step is to configure the script, is quite easy, you've to configure only few option, are all inside the easy_nordvpn script, so just nano or vi the script. The most important configutation is:
Code:
# Specify, comma separated, the country you want to connect from vpn, can be more than one.
# Just remember that must be the contry number, like 106 for Italy, or "228,202" for US and Spain at the same time
COUNTRYSELECTION_ID=""
Then
Code:
# Max load is usded to check the actual server load, if the load go over the MAX_LOAD, the script will change the vpn server.
# Don't select a too lower value, in this case the script will always change the server
MAX_LOAD=35
You can look inside the script to see other options, normally the value inserted are quite good, but you can change it if you need it.
So now you can reboot your router or just start the script via ssh with easy_nordvpn start
What I can do with the script?
Here a list of commands:
Code:
easy_nordvpn start -> This must be used only at boot, so don't use it if you don't know what're you doing
easy_nordvpn stop -> This stop the script execution
easy_nordvpn restart -> This will restart the entire script
easy_nordvpn status -> This check the actual status of vpn, actually check if connected and current server with load
easy_nordvpn force_connection -> This force a new connection, so if you use it the script connect to first best server.
easy_nordvpn interface_check -> This check only the VPN_INTERFACE, in order to check if is up and working
easy_nordvpn checkload -> This check the current server load, if is too low, make a new connection.
(note that the script connect to the new best server, but maybe this server already have higher load so at the next check the script will change again, and so on)
I want to thank egc for the infinite patience!
For now is all, if you've any question please ask, I would try to do my best to change possible errors.
Jo
Last edited by Chryses on Tue Jun 18, 2019 5:02; edited 5 times in total
First of all, thanks for creating this script!!
However, I'm having great struggles installing JQ.
I have no idea what it is and I can't figure out how to install it correctly.
PuTTY is currently displaying the next message:
Starting vpn script ...
easy_nordvpn is restarting ... please wait
Starting from scratch ...
Removing scripts
Taking down OpenVPN Client Routes
Shutting Down OpenVPN...
Restarting dnsmask service
Starting from scratch ...
Vpn connection script called
Let's see if all is good to start ...
Jq bin not found, I can't work without it, please install it and try again!!!
I just can't get Entware installed. Tried everything. This is the best result I got:
wget -O - http://pkg.entware.net/binaries/mipsel/installer/in
staller.sh | sh
Connecting to pkg.entware.net (104.27.176.50:80)
Info: Creating folders...
Info: Deploying opkg package manager...
Downloading /opt/bin/opkg... success!
Downloading /opt/etc/opkg.conf... success!
Downloading /opt/etc/profile... success!
Downloading /opt/etc/init.d/rc.func... success!
Downloading /opt/etc/init.d/rc.unslung... success!
Info: Basic packages installation...
Downloading http://pkg.entware.net/binaries/mipsel/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware-ng
Installing ldconfig (1.0.17-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/ldconfig_1.0.17-1_mipselsf.ip k
Installing findutils (4.6.0-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/findutils_4.6.0-1_mipselsf.ip k
Installing libc (1.0.17-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/libc_1.0.17-1_mipselsf.ipk
Installing libgcc (5.4.0-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/libgcc_5.4.0-1_mipselsf.ipk
Installing libssp (5.4.0-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/libssp_5.4.0-1_mipselsf.ipk
Configuring ldconfig.
Configuring libgcc.
Configuring libc.
Configuring libssp.
Configuring findutils.
Collected errors:
* extract_archive: Cannot create symlink from ./opt/lib/ld-uClibc.so.0 to 'ld-u Clibc.so.1': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/ld-uClibc.so.1 to 'ld-u Clibc-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libc.so.0 to 'libuClibc -1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libc.so.1 to 'libuClibc -1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libcrypt.so to 'libcryp t.so.1': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libcrypt.so.0 to 'libcr ypt-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libcrypt.so.1 to 'libcr ypt-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libdl.so to 'libdl.so.1 ': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libdl.so.0 to 'libdl-1. 0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libdl.so.1 to 'libdl-1. 0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libm.so to 'libm.so.1': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libm.so.0 to 'libm-1.0. 17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libm.so.1 to 'libm-1.0. 17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libnsl.so to 'libnsl.so .1': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libnsl.so.0 to 'libnsl- 1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libnsl.so.1 to 'libnsl- 1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libresolv.so to 'libres olv.so.1': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libresolv.so.0 to 'libr esolv-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libresolv.so.1 to 'libr esolv-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libuargp.so to 'libuarg p.so.1': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libuargp.so.1 to 'libua rgp-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libutil.so to 'libutil. so.1': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libutil.so.0 to 'libuti l-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libutil.so.1 to 'libuti l-1.0.17.so': Operation not permitted.
* extract_archive: Cannot create symlink from ./opt/lib/libssp.so.0 to 'libssp. so.0.0.0': Operation not permitted.
ln: /opt/etc/TZ: Operation not permitted
Congratulations! If there are no errors above then Entware-ng is successfully in itialized.
Starting from scratch ...
Vpn connection script called
Let's see if all is good to start ...
Ready to establish a new vpn connection
Selecting and making server configuration files
/opt/bin/easy_nordvpn: line 376: jq: Permission denied
Someting goes wrong during server selection, better restart all.
la variabile è:
############## CONFIGURATIONS ##############
# Specify, comma separated, the country you want to connect from vpn, can be more than one.
# Just remember that must be the contry number, like 106 for Italy, or "228,202" for US and Spain at the same time
COUNTRYSELECTION_ID="228"
# Here you've to select the Server Technology, only one can be used!
# Server technology -> ID
# OpenVPN UDP -> 3
# OpenVPN TCP -> 5
SERVER_TECHNOLOGIES_ID=3
# Here you've to select the Server group, only one can be used!
# Server group -> ID
# Double VPN -> 1
# Onion over VPN -> 3
# Dedicated IP -> 9
# Standard VPN -> 11
# P2P -> 15
SERVER_GROUP=15
# How many server you want to query? With 10 you'll ask for the top 10 server for each country, then the script will select the best one.
MAX_QUERY_SERVERS=10
# Max load is usded to check the actual server load, if the load go over the MAX_LOAD, the script will change the vpn server.
# Don't select a too lower value, in this case the script will always change the server
MAX_LOAD=35
# Which interface for the vpn?
VPN_INTERFACE="tun1"
# Which server do you want to ping?
PING_SERVER=8.8.8.8
# Interface check watchdog - time till checks (value rappresent seconds) If value greather than 0 the script will generate a watchdog script that run every X seconds
INTERFACE_CHECK_WATCHDOG_DELAY=60
# Interface check watchdog - time till checks (value rappresent seconds) If value greather than 0 the script will generate a watchdog script that run every X seconds
LOAD_CHECK_WATCHDOG_DELAY=3600
# Create a log file? 1 to enable (normally is only for debug purpose)
ENABLELOG="0"
############## CONFIGURATIONS ##############
I just changed (as far as I know) the countryselection to use the US servers.
Mmm. I suspect that you're not with root privilege.
Let me guess, you run the ssh connection from winscp?
In theory the script will start after a reboot, if you put the autostart line
So you can try to reboot the router and see if works.
But if you want to try by hand via ssh connection you've to be root, so use putty to connect and use root user (obviously I'm thinking that you're not root, maybe I'm wrong)
I've to investigate why there's permission denied error
PS try to
chmod 777 pathtonordvpn script file
Maybe the permission is wrong