English
Ask Your Question
0

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.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
edit retag flag offensive close delete

Comments

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

2 Answers

Sort by » oldest newest most voted
2

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:

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

[Service]
Type=forking
PIDFile=/var/run/openvpn/<server>.pid
ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/<server>.pid --cd /etc/openvpn/ --config <server>.conf

[Install]
WantedBy=multi-user.target

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 publish link more
0

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 publish link more

Comments

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

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

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 to your questions.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question tools

Follow
1 follower

Stats

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

Seen: 4,104 times

Last updated: Mar 04 '13