Home > bash, Fedora 20, Linux, OpenVPN, RHEL > Fedora release 20 (Heisenbug) enable client OpenVPN service on boot

Fedora release 20 (Heisenbug) enable client OpenVPN service on boot

In short, I had to deal with the Fedora EVIL EVIL EVIL !!! Systemd
I found my openvpn startup script useless ..
Managed to set the VPN at the Network Manager just loading the openvpn config file, but I wanted to be started on boot … because out of the blue my Fedora 20 Gnome boot hanged on the blue logo !!! This is another story to be told.

Anyway, back to the OpenVPN issue, the steps to do make it start on boot, following the instructions at http://fedoraproject.org/wiki/Openvpn

1. Set the keys and the config file at /etc/openvpn

root@outoutdragkh.f20:[Thu Aug 21 01:30:06][~]$ cd /etc/openvpn/
root@outdragkh.f20:[Thu Aug 21 01:30:10][/etc/openvpn]$ ls
keys  outdragkh.client.conf

2. Fix selinux context of the config files :

root@outdragkh.f20:[Thu Aug 21 01:30:10][/etc/openvpn]$  restorecon -Rv /etc/openvp

3. Check the general openvpn service file:

root@outdragkh.f20:[Thu Aug 21 01:30:32][/etc/openvpn]$ ls /lib/systemd/system/openvpn\@.service
/lib/systemd/system/openvpn@.service
root@outdragkh.f20:[Thu Aug 21 01:30:51][/etc/openvpn]$ cat /lib/systemd/system/openvpn\@.service
[Unit]
Description=OpenVPN Robust And Highly Flexible Tunneling Application On %I
After=syslog.target network.target

[Service]
PrivateTmp=true
Type=forking
PIDFile=/var/run/openvpn/%i.pid
ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf

[Install]
WantedBy=multi-user.target

4. Set the systemd start scripts for the outoutdragkh.client.conf

root@outdragkh.f20:[Thu Aug 21 01:30:55][/etc/openvpn]$ ln -s /lib/systemd/system/openvpn\@.service /etc/systemd/system/multi-user.target.wants/openvpn\@outdragkh.client.service
root@outdragkh.f20:[Thu Aug 21 01:32:04][/etc/openvpn]$ ls /etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service 
/etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service

5. Enable the dragkh OpenVPN service

root@outdragkh.f20:[Thu Aug 21 01:32:12][/etc/openvpn]$ systemctl -f enable openvpn@outdragkh.client.service
rm '/etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service'
ln -s '/usr/lib/systemd/system/openvpn@.service' '/etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service'

6. Start the dragkh OpenVPN service

root@outdragkh.f20:[Thu Aug 21 01:32:30][/etc/openvpn]$ systemctl start openvpn@outdragkh.client.service 
root@outdragkh.f20:[Thu Aug 21 01:32:49][/etc/openvpn]$ systemctl status openvpn@outdragkh.client.service 
openvpn@outdragkh.client.service - OpenVPN Robust And Highly Flexible Tunneling Application On outdragkh.client
   Loaded: loaded (/usr/lib/systemd/system/openvpn@.service; enabled)
   Active: active (running) since Thu 2014-08-21 01:32:49 CEST; 5s ago
  Process: 3194 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=0/SUCCESS)
 Main PID: 3195 (openvpn)
   CGroup: /system.slice/system-openvpn.slice/openvpn@outdragkh.client.service
           └─3195 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/outdragkh.client.pid --cd /etc/openvpn/ --config outdragkh.client.conf

Aug 21 01:32:49 dragkh.wordpress.com systemd[1]: Started OpenVPN Robust And Highly Flexible Tunneling Application On outdragkh.client.
root@outdragkh.f20:[Thu Aug 21 01:32:55][/etc/openvpn]$ systemctl status openvpn@outdragkh.client.service 

done …

Slackware2Life 🙂

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: