0

I am trying to connect VPN during bootup of my new Ubuntu 18.04.4 LTS system. I am new to Linux. This is a new installation on an old Gateway laptop built for WindowsXP. It runs on 1GB RAM and an AMD Turion 64 (1.6Ghz) processor. I have spent 20-30 hours during the last week scouring tutorials and forums including AskUbuntu, attempting the simple sounding suggestions, re-reading, double-checking my work, etc. As far as I can tell I have tried every option described... without success. The three basic options I found are:

  1. Use Connection Manager
  2. Setup OpenVPN as a service
  3. Run a script at bootup

Option 1
I used the Nm-connection-manager to install the .ovpn file provided by ExpressVPN. Then I opened the settings of my LAN connection where I navigated to the General tab and checked the box to Automatically connect to VPN when using this connection (I only have the one .ovpn loaded so it selected that option for me by default). Then I hit save and rebooted. VPN did not connect, but the LAN connection did just fine. I went back to the Connection Manager and saw that the little check box was now unchecked. Figuring I might have skipped saving the change, I again checked the box. Then I clicked SAVE with all my focus and intention. Reboot. Same story: No VPN and box is unchecked.

Option 2: Here are the steps I took to run VPN as a service

A. Installed OpenVPN.
B. Downloaded the appropriate .ovpn configuration file from my VPN provider (ExpressVPN) and copied it to /etc/openvpn/openvpn.conf.
C. Created auth.txt in the same folder, and put my username on the first line and password on the second line.
D. Added ¨auth.txt¨ on the last line of openvpn.conf at the end of the last line which says ¨auth-user-pass¨
E. Ran $ update-rc.d openvpn default

Result: Does not connect at bootup

Option 3: Steps I took to run a script during bootup:

A. Create a text file in /etc/init.d called script.sh containing:

    #!/bin/bash
    expressvpn connect  

B. Run $ chmod 755
C. Run $ sudo update-rc.d script.sh defaults

Note: $ expressvpn connect is what I currently use to successfully connect to my VPN server. I currently do this every time I boot the computer.
Result: I see that script.sh shows up as bright green alongside the other contents of init.d, but the VPN does not connect during bootup.

Overall conclusion: I am not confident that any scripts in /etc/init.d are being run at bootup. I tried running other scripts at bootup without success.

If you have read all of this you may be some sort of saint. I would be grateful for any suggestions.

hoatzin
  • 568
  • I'm having trouble understanding why you dismiss Option 1. Your stated requirement is to connect during boot, and by definition that can't be to a new connection. Are you actually asking "How to force VPN usage on every connection" and the "bootup" part is misleading? – Organic Marble May 07 '20 at 21:29
  • 1
    I have now changed the wording of the question per your suggestion. Thanks. – hoatzin May 07 '20 at 21:47
  • Anyway, I did that try option 1 as well, and it doesnt work either. I will add those details as well. – hoatzin May 07 '20 at 22:02
  • Hmm, Option 1 ticking the box "automatically connect to VPN when using this connection" has always worked for me. I understand that does not meet your needs though since it does not cover new connections.

    Now that it's clarified, I have found a couple of other people on the site asking for a similar thing, but unfortunately all the questions are old and don't have accepted answers. Such as https://askubuntu.com/q/160048/243321 https://askubuntu.com/q/47048/243321 https://askubuntu.com/q/26793/243321

    – Organic Marble May 07 '20 at 22:02
  • These links you provided are certainly on topic. They seem a little over my head. It seems like they include variables that might be easy for a more experienced user to solve. Am I trying to do something unusual? I assume that all Ubuntu users using a VPN would want their computers to do the same thing. Right? – hoatzin May 07 '20 at 22:52
  • I think a user who normally used a few connections would just tick the box in Network Manager "automatically connect to VPN when using this connection" on those connections. (My interest in this is that I set up my own OpenVPN server and I'm still in the learning mode, I am no expert). If there is a way to force any new connection to use the VPN without the user taking any action I don't know what it would be, but I am interested in the topic. – Organic Marble May 07 '20 at 22:55
  • I am trying your #2 now... it might just be your type but it only ran for me with E. Ran $ sudo update-rc.d openvpn defaults , note the defaults not default. – pierrely Feb 19 '21 at 05:43

1 Answers1

0

I stumbled upon a decent solution by accident:

expressvpn autoconnect true

I dont know why it doesnt install that way by default.

hoatzin
  • 568
  • my nordvpn sometimes works that way, and sometimes does not... the #2 solution above did not work, and "it is the ubuntu way" now on reboots brings up login/pass field for ubuntu even though I have autologin set, and lo and behold, even logs me in properly if I put rubbish username/password into it. tar babies. – pierrely Feb 19 '21 at 05:59