wknapik / openvpn-unroot

Run OpenVPN without root privileges
MIT License
31 stars 7 forks source link

Feature Request: Create/remove tun device dynamically #11

Open jonjonw opened 6 years ago

jonjonw commented 6 years ago

Instead of creating an entry in /etc/systemd/network, you could create the tun device in the unit file (and destroy it after as well). This would keep the list of links less cluttered when it's not running.

To do this, you can delete the systemd-network netdev file and add a file at /etc/systemd/system/openvpn-client@{configname}.service.d/tuntap.conf containing:

[Service] ExecStartPre=+/usr/bin/ip tuntap del name tun-pia mode tun ExecStartPre=+/usr/bin/ip tuntap add name tun-vpn mode tun user openvpn group openvpn ExecStopPost=+/usr/bin/ip tuntap del name tun-vpn mode tun

Replacing tun-vpn and the user/group as needed.