Always-on-VPN Working
-
I was able to get an always-on-vpn using crontab. Warning I haven't tried to find a way yet to turn it off, so if you need to turn off your VPN from time to time, I don't have an answer yet.
*Make sure to make your terminal Read/Write during this whole process. It's Read-Only by default. I used the UT Tweak Tool to do this.
I used this script (https://www.gabsoftware.com/tips/automatically-reconnect-to-your-vpn-on-linux/) as a template to automatically reconnect to my VPN when it turned off.
I used this terminal command with my VPN turned on, nmcli c show --active | grep vpn, to find out my personal MyVPNConnectionName and my UUID number. I also replaced sleep 30 with sleep 5, but that's just a personal preference.
After replacing MyVPNConnectionName and the UUID number in the script with your personal VPNName and UUID number, I recommend copy/paste the script into the terminal and let it run, toggle off your VPN and see if it toggles back on automatically. If it does not toggle back, then you'll have to go back and correct the script, whatever that correction may be. Personally, it didn't work for me the first time, because I had deleted the "" around "MyVPNConnectionName" and had to go back and re-add them.
I then used this website (https://linuxhandbook.com/run-shell-script/) to save the script. This website says to make a scripts directory (mkdir scripts) which I did not do. Making a scripts directory probably won't have any affect on this, but I can't say for sure, because I didn't do it. If you do make a scripts directory, cd into scripts or whatever you named your scripts directory. For this example I'll refer to the directory as scripts.
When you type cat > vpn.sh (I'm using vpn.sh, you can name it anything you want as long as it ends in .sh) into the terminal, the terminal will look like it's "thinking" but this is where you copy/paste your working script into the terminal. After I hit Ctrl+D to save it, my terminal closed, but it did save. When you reopen the terminal, make sure it's Read-Write if you didn't use the UT Tweak Tool.
Then make the script executable in the terminal by typing in chmod u+x vpn.sh (make sure you cd into the scripts directory if you made one)
I then typed chmod 755 vpn.sh (I don't know if this did anything at all, but I did it, this may not be necessary)
Test the script (if you made a scripts directory cd into scripts) type bash vpn.sh into the terminal to activate the script and toggle off the VPN to see if it turns back on automatically. Hit Ctrl+C to clear the script.
To make this script turn on automatically all the time, type crontab -e into the terminal. Pick 1 nano <---- easiest and hit enter. If you've never used nano don't use your fingers to scroll down. Long-press the hamburger menu at the top left side of the keyboard and pick Scr. Swipe left on the top of the keyboard next to hamburger menu till you get to the scroll buttons and use those to scroll down to the bottom of the crontab directly below the last #.
There type in @reboot /home/phablet/./vpn.sh
if you made a scripts directory, type in @reoot /home/phablet/scripts/./vpn.shLong-press the hamburger menu again and choose Nano. Then find Ctrl+X and press it. Then hit y then enter. Then hit enter again, and it should take you back to the normal terminal.
Reboot your phone
After reboot, before I unlock my phone, I get a VPN error notification. After I unlock my phone with the passcode this notification goes and my VPN turns on automatically. Even when I relock my phone, the automatic VPN continues to work just fine.
Remember, as of right now, I cannot turn off my VPN, I haven't tried to find a way either.
-