A simple systemd service, intended to maintain a persistent VPN connection.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is a simple systemd service, built to help learn the basics of systemd, while solving an annoyance with Ubuntu.

It is intended to ensure that a particular VPN connection remains persistently connected.


  • Linux running systemd (tested on Ubuntu 16.04)
  • Ruby
  • An active VPN connection


  • Copy peristentvpn to somewhere appropriate (for example, /usr/local/bin)
  • Edit persistentvpn.service:
    • change path to persistentvpn file, if it is not /usr/local/bin
    • change CONNECTION_NAME=xyz: xyz should be the name of your VPN connection, as found in Network Manager or nmcli conn
  • Copy persistentvpn.service to /etc/systemd/system/
  • systemctl start persistentvpn.service

To start automatically on boot, run this once:

  • systemctl enable persistentvpn.service


This software does not guarantee that the VPN connection is active 100% of the time, nor that no traffic flows over other connections. It will simply automatically attempt to reconnect to the given VPN after a few seconds. During this reconnection period, or if VPN connection fails, internet traffic may be routed over other connections, dependent on your network configuration.