Wednesday, April 17, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1668  / 2 Years ago, sun, august 7, 2022, 10:05:48

I can connect to my VPN server with command:


 sudo openvpn confyg.ovpn

Everything runs fine, but what is the best way to start openvpn client and connect to server when system starts?


More From » startup

 Answers
0

Use systemd


In order to configure OpenVPN to autostart using systemd, complete the following steps:


Run the command:


sudo nano /etc/default/openvpn

and uncomment, or remove, the “#” in front of


AUTOSTART="all"

then press Ctrl+O followed by Enter to save the changes and Ctrl+X to exit the text editor.


Copy the .ovpn file with the desired server location to the ‘/etc/openvpn’ folder:


sudo cp /location/whereYouDownloadedConfigfilesTo/confyg.ovpn /etc/openvpn/    

Edit the .ovpn file you copied in the previous step and change the line ‘auth-user-pass’ to ‘auth-user-pass pass’:


sudo nano /etc/openvpn/confyg.ovpn

then press Ctrl+O followed by Enter to save the changes and Ctrl+X to exit the text editor.


In the ‘/etc/openvpn’ folder, create a text file called pass:


sudo nano /etc/openvpn/pass

and enter your VPN Account ID on the first line and VPN passwordon the 2nd line, then press Ctrl+O followed by Enter to save the changes and Ctrl+X to exit the text editor.


Change the permissions on the pass file to protect the credentials:


sudo chmod 400 /etc/openvpn/pass

Rename the .ovpn file to ‘client.conf’:


sudo mv /etc/openvpn/confyg.ovpn /etc/openvpn/client.conf

Enable the Openvpn@ service with the following command:


sudo systemctl enable [email protected]

Reload the daemons:


sudo systemctl daemon-reload

Start the OpenVPN service:


sudo service openvpn@client start

Reboot and test if it is working by checking the external IP.


Adapted from: https://www.ivpn.net/knowledgebase/linux/linux-autostart-openvpn-in-systemd-ubuntu/


Hope this helps


[#817] Monday, August 8, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ormlai

Total Points: 292
Total Questions: 106
Total Answers: 115

Location: Cape Verde
Member since Fri, Sep 16, 2022
2 Years ago
ormlai questions
Wed, Sep 28, 22, 00:17, 2 Years ago
Wed, Jun 16, 21, 03:50, 3 Years ago
Sun, Feb 6, 22, 09:11, 2 Years ago
Mon, Jul 12, 21, 10:00, 3 Years ago
Sat, Jun 25, 22, 07:55, 2 Years ago
;