7

Hi i bought vpn access form a vpn provider, i got a bunch of .ovpn files.

How can i get openvpn to startup one of these .opvn files under start/boot up?

I would like to, not have to run openvpn --config VPNservername.ovpn every time i have to do a reboot. I'm running ubuntu 12.04 server.

I have installed openvpn

starR
  • 427
  • 2
  • 6
  • 14

5 Answers5

13

When you have installed openvpn from the repo, everything is already prepared for you.

Place the whatever.conf file in /etc/openvpn/ and a daemon will be started for it at boot.

Edit

Please note that *.opvn will not work, *.conf will.

2

Note, that /etc/default/openvpn file contain AUTOSTART option. You can add there all your configs without .conf at the end you want to autostart. But don't forget to do:

systemctl daemon-reload

after editing it.

AstraSerg
  • 130
  • 1
    This is irrelevant to this question as it was asked a long time ago and the OP is running Ubuntu 12.04. And it dosen't seem the OP is going to accept - he hasn't been on for 3 months. – fosslinux Jul 22 '16 at 05:09
  • 5
    Nevertheless, I believe it could help people, who's looking for the answers with similar problems. – AstraSerg Jul 24 '16 at 06:39
  • @ubashu I don't think this is irrelevant. Answers should change based on newer versions of software. This is the top result for me when I search. – Allison May 30 '17 at 05:17
  • This helped me a lot today and should be upvoted, thanks for the answer @AstraSerg – TheCatWhisperer Oct 28 '18 at 20:14
0

Put the keys, certificates, and client configuration file in the proper folders...

/etc/openvpn/ca.crt
/etc/openvpn/client/client0.crt
/etc/openvpn/client/client0.key
/etc/openvpn/client/ta.key
/etc/openvpn/client/client0.conf

Enable OpenVPN client service to start at boot and start it...

systemctl enable openvpn-client@client0
systemctl start openvpn-client@client0

NOTE: In the example "client0" is the name of the configuration chosen!

TIP: Client configuration example...

client
remote <OPENVPN_SERVER_IP_OR_NAME> 1194
dev tun
proto udp
resolv-retry infinite
nobind
persist-key
persist-tun
verb 3
cipher AES-256-CBC
keepalive 10 120
compress lz4-v2
auth-nocache
remote-cert-tls server

ca /etc/openvpn/ca.crt
cert /etc/openvpn/client/client0.crt
key /etc/openvpn/client/client0.key
tls-auth /etc/openvpn/client/ta.key 1

Thanks! =D

0

I had to move the ca.crt into the /etc/openvpn/client directory and renamed .ovpn to .conf. Then it worked.

Eliah Kagan
  • 117,780
1av8r
  • 1
0

If on ubuntu server: go to rc.local. vi /etc/rc.local add the following line openvpn --config /your/path/file.ovpn save and reboot.