I do have a list of *.ovpn
configuration inside the directory of /etc/openvpn/ovpn_tcp/
inside that directory i do have a bash script called go
include the following code which will pickup random server from the list and connect to it.
#!/bin/bash
set -- *.nordvpn.com.tcp.ovpn
shift $(( RANDOM % $# ))
openvpn "$1"
I tried to create alias to call the script by the following.
alias vpn='bash /etc/openvpn/ovpn_tcp/go'
But it's keep giving me an error
Options error: In [CMD-LINE]:1: Error opening configuration file: *.nordvpn.com.tcp.ovpn
Use --help for more information.
But if i call it by the following alias so it's will run without any issue.
alias vpn='cd /etc/openvpn/ovpn_tcp/ && bash go'
Usually i open screen
session to connect to the vpn
and then detached it and once I'm done so i reattach to it and then use CTRL + C
to cancel the vpn
connection.
What I'm looking for is to set 2
aliases
1- alias to turn on the vpn without needing to open screen
session or busy the current terminal and once the vpn connected i want to make sure it's connected by calling curl ifconfig.co
to view the IP
.
2- alias to turn off the vpn.
NOTE:
Are it's possible to prevent the alias
which turn on the vpn to run in case if if we are already connected to VPN?