How to Auto Start OpenVPN Client on Ubuntu Bionic

Launch OpenVPN client as a daemon.

Here I assume you already have your own cert file - filename.ovpn. ๐Ÿ™‚
Modify its file extension to conf like so:

1mv filename.ovpn filename.conf 

Put your cert file inside /etc/openvpn directory like so:

1mv /path/to/filename.conf /etc/openvpn/

OpenVPN client service name would be openvpn@filename.
Well, you might already know what to do to launch the service.

1sudo killall openvpn
2sudo systemctl enable --now openvpn@filename

Reload the system daemons.

1sudo systemctl daemon-reload

That's it. ๐Ÿ™‚

If you have username and password for the certfile, you need this step

Make a credential file like so:

1sudo touch /etc/openvpn/login.conf

Enter the following into the file.

1your-username
2your-password

Open your certfile to edit.

1sudo vim /etc/openvpn/filename.conf

Add this line or edit it if it already exists.

1auth-user-pass login.conf

If you want to launch it manually each time, I recommend a shell script

Write a shell script with the following contents.

1#!/bin/bash
2sudo killall openvpn
3sudo openvpn --daemon --config /path/to/filename.ovpn

You can now use the script file whenever you need it, even on startup.

Happy networking! ๐Ÿ™‚