I’m wanting to run an OpenVPN client on a Debian machine. I can see the service is running:

# sudo service openvpn status
● openvpn.service - OpenVPN service
   Loaded: loaded (/lib/systemd/system/openvpn.service; enabled; vendor preset: enabled)
   Active: active (exited) since Thu 2017-12-28 19:01:14 UTC; 1h 8min ago
  Process: 19416 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 19416 (code=exited, status=0/SUCCESS)

And I can start OpenVPN via the daemon so that it runs in the background

# sudo openvpn --config /etc/openvpn/client.conf --daemon

I can confirm that it’s running as expected via it’s logging as well as checking my WAN IP.

However, I can stop the OpenVPN service…

# sudo service openvpn stop
# sudo service openvpn status
● openvpn.service - OpenVPN service
   Loaded: loaded (/lib/systemd/system/openvpn.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Thu 2017-12-28 20:10:00 UTC; 37s ago
  Process: 19416 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 19416 (code=exited, status=0/SUCCESS)

But the daemon is still running in the background and I’m still connected to the VPN and I’m still getting a public VPN IP address.

So what is the difference between the service and daemon? Are they not dependent on each other?

My goal is to have the OpenVPN running in the background when the computer is booted up and for it to continue running indefinitely. I was just going to set the service to run on boot, but the above actions are now confusing me on how to accomplish that…

Update: Here is this file: /lib/systemd/system/openvpn.service

# This service is actually a systemd target,
# but we are using a service since targets cannot be reloaded.

[Unit]
Description=OpenVPN service
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecReload=/bin/true
WorkingDirectory=/etc/openvpn

[Install]
WantedBy=multi-user.target

Leave a Reply

Your email address will not be published. Required fields are marked *