Centos 7 and OpenVPN: how make them friends

centoscentos7openvpnselinux

I'm trying to install OpenVPN server on Centos 7 and faced with next problem:

[root@msk ~]# /etc/init.d/openvpn start
Starting openvpn (via systemctl):                          [  OK  ]
[root@msk ~]# ps aux | grep openvpn
root      5639  0.0  0.0 112640   980 pts/6    S+   12:54   0:00 grep --color=auto openvpn
[root@msk ~]# service openvpn start
Starting openvpn (via systemctl):                          [  OK  ]
[root@msk ~]# ps aux | grep openvpn
root      5657  0.0  0.0 112640   980 pts/6    S+   12:54   0:00 grep --color=auto openvpn
[root@msk ~]#

As you can see – nothing happens.

But if i'll try to start it with single command: openvpn --daemon --writepid /var/run/openvpn/openvpn.pid --config /etc/openvpn/server.conf --cd /etc/openvpn it works nice.

I think problem is selinux. And I don't want to disable it at all.

Could you point me where is error?

Best Answer

CentOS 7 uses systemd to control system service daemons. That you are using init scripts suggests that you have installed your openvpn without using a package manger ( the openvpn-2.3.2-4.el7 rpm doesn't contain init scripts)

I think at this point, rather than trying to debug and use init scripts it would be better to remove your current installation and then install and configure the natively supported package. Something like

yum install openvpn
systemctl enable openvpn@service.service

systemctl start openvpn@server.service
systemctl status -l openvpn@server.service

Notice the use of openvpn@server, this relates to the /etc/openvpn configuration file which in this case would be expected to be /etc/openvpn/server.conf. If for example you had openvpn listening on port 443 you could

systemctl enable openvpn@port443.service

and you would complement that with a /etc/openvpn/port443.conf.