Ubuntu: Automatically turn on VPN on computer unlock Ubuntu 18.04



Question:

When I wake the laptop from the sleep I need to get the VPN state as I left it (turned on). Can't find the setting of autoconnect in VPN settings... Need some easy way to ask the system to autoconnect the VPN when the internet is available.

Edit based on comments:

Ubuntu 18.04 has no option to Always connect to VPN when using using this connection. enter image description here


Solution:1

If you go into your WiFi connection settings for the AP you want to connect to the VPN on, there is an Always connect to VPN when using this connection: option, which you can enable, and select the VPN which you wish to automatically connect to.

Then when you connect to this connection (or when it reconnects on wake from suspend), the system will also attempt to connect to the VPN upon successfully reconnecting to the designated WiFi AP.

It seems the changes in newer GNOME have removed this option from the main UI, so you need to run nm-connection-editor to edit the connection, which should make the option available again.


Solution:2

When OpenVPN is already installed on your computer and have the configurations for OpenVPN, then follow this steps:

  1. Unpack the configuration-zip: unzip openvpn.zip
  2. Move to the OpenVPN directory and rename it to “openvpn.conf.”: sudo cp ~/Downloads/OpenVPN/'Northeast US.ovpn' /etc/openvpn/openvpn.conf
  3. To login automatically every time you connect do this: Open “/etc/openvpn/openvpn.conf” with sudo, then search for the line auth-user-pass and add auth.txt. ----> How does it looks like: auth-user-pass auth.txt! Crate the file in the following directory "/etc/openvpn”and type in there your username and password. More about that here.
  4. Make sure OpenVPN starts up every time you turn-on your computer: sudo systemctl enable openvpn
  5. Restart the computer and test your connection with services like whoer.net

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »