Ask Your Question

How to start Openvpn service at boot time

asked 2013-02-22 15:29:02 +0000

Cerin gravatar image

updated 2013-03-04 16:34:39 +0000

How do you configure the openvpn service to start when the computer boots?

Based on some other answers (which this board won't let me post links to apparently), this should simply be:

systemctl enable openvpn@server.service

but this just returns:

Failed to issue method call: No such file or directory

I can start/stop/find status of the service using

systemctl start openvpn@server.service
systemctl stop openvpn@server.service
systemctl status openvpn@server.service

I've also tried:

systemctl enable openvpn@service
systemctl enable openvpn.service

but these also result in "Failed to issue method call: No such file or directory"

[user@localhost ~]# systemctl|grep vpn
openvpn@...i-user.service loaded failed failed        OpenVPN Robust And Highly Flexible Tunneling Application On multi/user
openvpn@server.service    loaded active running       OpenVPN Robust And Highly Flexible Tunneling Application On server
[user@localhost ~]# rpm -qs openvpn|grep service
normal        /lib/systemd/system/openvpn@.service

[user@localhost ~]# ll /etc/openvpn
total 68
-rwxr-xr-x 1 root root   772 Jul 18  2011 bridge-start
-rwxr-xr-x 1 root root   316 Jul 18  2011 bridge-stop
-rw-r--r-- 1 root root    67 Jul 18  2011 client-connect.sh
-rw-r--r-- 1 root root    56 Jul 18  2011 client-disconnect.sh
drwxr-xr-x 4 root root  4096 Oct 19  2010 easy-rsa
-rw------- 1 root root   180 Feb 22 11:05 ipp.txt
drwx------ 2 root root  4096 Jan 22 10:49 keys
-rwxr-xr-x 1 root root   509 Jul 18  2011 nat-startup
-rwxr-xr-x 1 root root    45 Jul 18  2011 openvpn-shutdown
-rwxr-xr-x 1 root root    46 Jul 18  2011 openvpn-startup
-rw------- 1 root root   369 Feb 22 11:08 openvpn-status.log
-rw-r--r-- 1 root root 10916 Oct 10  2011 server.conf
-rw-r--r-- 1 root root 10562 Jul 18  2011 server.conf.orig

Showing successfully enabling and starting the service, rebooting, and then showing the service did not start:

[user@localhost ~]# ssh user@host
[user@host ~]# sudo systemctl status openvpn@server.service
openvpn@server.service - OpenVPN Robust And Highly Flexible Tunneling Application On server
      Loaded: loaded (/lib/systemd/system/openvpn@.service; enabled)
      Active: inactive (dead)
      CGroup: name=systemd:/system/openvpn@.service/server
[user@host ~]# sudo systemctl start openvpn@server.service
[user@host ~]# sudo systemctl status openvpn@server.service
openvpn@server.service - OpenVPN Robust And Highly Flexible Tunneling Application On server
      Loaded: loaded (/lib/systemd/system/openvpn@.service; enabled)
      Active: active (running) since Mon, 04 Mar 2013 11:22:14 -0500; 16s ago
     Process: 20585 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=0/SUCCESS)
    Main PID: 20586 (openvpn)
      CGroup: name=systemd:/system/openvpn@.service/server
          โ”” 20586 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/server.pid --cd /etc/openvpn/ --config server.conf
[user@host ~]# sudo reboot

Broadcast message from user@host on pts/0 (Mon, 04 Mar 2013 11:23:01 -0500):

The system is going down for reboot NOW!

[user@localhost ~]# Connection to host closed by remote host.
[user@localhost ~]# ssh user@host
[user@host ~]# sudo systemctl status openvpn@server.service
openvpn@server ...
edit retag flag offensive close merge delete


Anything show up with systemctl|grep vpn or rpm -qs openvpn|grep service ?

randomuser ( 2013-02-22 15:34:50 +0000 )edit

@randomuser, I've appended the output of those commands to my question.

Cerin ( 2013-02-22 15:59:40 +0000 )edit

Also put the output of ll /etc/openvpn/

lnxslck ( 2013-02-22 16:01:18 +0000 )edit

the '@' in a service name typically indicates a service that can run multiple instances. I can't think of how to enable one offhand, but perhaps this will point you in the right direction.

randomuser ( 2013-02-22 16:02:53 +0000 )edit

@lnxslck, Done.

Cerin ( 2013-02-22 16:12:31 +0000 )edit

5 answers

Sort by ยป oldest newest most voted

answered 2013-03-04 19:02:50 +0000

Cerin gravatar image

It seems this is a known bug/limitation in the design of the Systemd framework in combination with OpenVPN. Since OpenVPN supports multiple servers, each daemon requires a separate configuration file, which Systemd does not support "out of the box". The solution is to create a /etc/systemd/system/<server>.service file for each openvpn <server>.conf file.

Mine looks like:

Description=OpenVPN Robust And Highly Flexible Tunneling Application On <server>
After=syslog.target network.target

ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/<server>.pid --cd /etc/openvpn/ --config <server>.conf


Replace <server> with the name of your configuration file.

Then, I simply call:

sudo systemctl enable <server>.service
sudo systemctl start <server>.service

After I rebooted, the service was started automatically.

edit flag offensive delete link more


Great info, this helped me soooo much. Last time I set up openvpn on fedora to connect at boot it took me forever to figure out, this time 10mins. I did have an issue though where sometimes it would connect normally, sometimes it wouldn't connect at all, and sometimes it would connect twice. Turns out I had duplicate files, names slightly different, in multi-user.target.wants. I deleted one and everything works great. Thanks again

jbodhorn ( 2015-09-26 23:55:46 +0000 )edit

Hi there, I have recently started using Linux and am now trying to configure my PIA VPN. I have configured my PIA VPN and can now run it manually, but can't get it to work to run on boot.

When installing, I had to handle a ".ca" file (certificate, from what I understood), however, I don't have or can't find a <server>.conf file. Therefore, I can't follow the above directions.

I would be most grateful if you could help me with this!

edit: I am using Fedora 23 and the only file I have in /etc/openvpn is a ca.crt file.

rxis ( 2016-03-29 08:40:15 +0000 )edit

answered 2017-07-21 21:26:50 +0000

rhcev6 gravatar image

systemctl enable openvpn@server.service Created symlink /etc/systemd/system/multi-user.target... โ†’ /usr/lib/systemd/system/openvpn@.service.

the format of these multi-instance commands (for openvpn anyway) is openvpn@xxxxx.service where xxxxx -s the name of the config file. so for openvpn@server.service the config file is /etc/openvpn/server.conf. If I has a second config names /etc/openvpn/server2.conf then I would enable/disable/start/stop openvpn@server2.service

edit flag offensive delete link more

answered 2013-02-22 15:58:46 +0000

Aleksandar Kostadinov gravatar image

updated 2013-02-22 20:23:33 +0000

try (notice sudo):

$ sudo systemctl enable openvpn@.service
edit flag offensive delete link more


This makes sudo systemctl status openvpn@server.service list the service as "enabled", but it still fails to start and is still listed as "inactive (dead)" after a reboot.

Cerin ( 2013-03-04 16:29:31 +0000 )edit

answered 2015-02-23 16:13:57 +0000

This works for me on Fedora 21 and Centos 7:

cd /etc/systemd/system/multi-user.target.wants/
ln -s /usr/lib/systemd/system/openvpn@.service openvpn@server.service
edit flag offensive delete link more

answered 2018-02-28 14:50:00 +0000

mikmik gravatar image

Systemd startscripts were bit changed in Fedora, but it seems it is not documented anywhere. The idea is that you could have multiple config files in /etc/openvpn/ directory and you can use systemd to start with different configs. For example assume you have got on config in /etc/openvpn/serverudp.conf and the other one /etc/openvpn/servertcp.conf, which differ only by having "proto udp" and "proto tcp".

Then you enable these services by:

systemctl enable openvpn-server@serverudp.service
systemctl enable openvpn-server@servertcp.service

You start them with these commands and they will use the respective config files:

systemctl start openvpn-server@serverudp.service
systemctl start openvpn-server@servertcp.service

Best regards

Michal Ambroz

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

1 follower


Asked: 2013-02-22 15:29:02 +0000

Seen: 34,862 times

Last updated: Feb 28