README.systemd 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. OpenVPN and systemd
  2. ===================
  3. As of OpenVPN v2.4, upstream is shipping systemd unit files to provide a
  4. fine grained control of each OpenVPN configuration as well as trying to
  5. restrict the capabilities the OpenVPN process have on a system.
  6. Configuration profile types
  7. ---------------------------
  8. These new unit files separates between client and server profiles. The
  9. configuration files are kept in separate directories, to provide clarity
  10. of the profile they run under.
  11. Typically the client profile cannot bind to any ports below port 1024
  12. and the client configuration is always started with --nobind.
  13. The server profile is allowed to bind to any ports. In addition it enables
  14. a client status file, usually found in the /run/openvpn-server directory.
  15. The status format is set to version 2 by default. These settings may be
  16. overridden by adding --status and/or --status-version in the OpenVPN
  17. configuration file.
  18. Neither of these profiles makes use of PID files, but OpenVPN reports back to
  19. systemd its PID once it has initialized.
  20. For configuration using a peer-to-peer mode (not using --mode server on one
  21. of the sides) it is recommended to use the client profile.
  22. Configuration files
  23. -------------------
  24. These new unit files expects client configuration files to be made available
  25. in /etc/openvpn/client. Similar for the server configurations, it is expected
  26. to be found in /etc/openvpn/server. The configuration files must have a .conf
  27. file extension.
  28. Managing VPN tunnels
  29. --------------------
  30. Use the normal systemctl tool to start, stop VPN tunnels, as well as enable
  31. and disable tunnels at boot time. The syntax is:
  32. - client configurations:
  33. # systemctl $OPER openvpn-client@$CONFIGNAME
  34. - server configurations:
  35. # systemctl $OPER openvpn-server@$CONFIGNAME
  36. Similarly, to view the OpenVPN journal log use a similar syntax:
  37. # journalctl -u openvpn-client@$CONFIGNAME
  38. or
  39. # journalctl -u openvpn-server@$CONFIGNAME
  40. * Examples
  41. Say your server configuration is /etc/openvpn/server/tun0.conf, you
  42. start this VPN service like this:
  43. # systemctl start openvpn-server@tun0
  44. A client configuration file in /etc/openvpn/client/corpvpn.conf is
  45. started like this:
  46. # systemctl start openvpn-client@corpvpn
  47. To view the server configuration's journal only listing entries from
  48. yesterday and until today:
  49. # journalctl --since yesterday -u openvpn-server@tun0