Skip to content

Simple bash script to disconnect OpenVPN clients after a specific connected time

Notifications You must be signed in to change notification settings

thalla2/kill-openvpn-clients

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

The OpenVPN server (community edition) doesn't support a "max connected" time. This simple script will generate a list of users currently connected to the VPN and kill their session automatically once they reach the max connected time.

Requirements:

  • OpenVPN community edition
  • nc
  • The 'management' value defined on in OpenVPN's server.conf

[root@vpn:/root]$ grep management /etc/openvpn/server/server.conf
management 127.0.0.1 7505
[root@vpn:/root]$

Install:

  • Download kill_vpn_clients.sh and place it on your server
  • Edit the PORT, KILLTIME and TMPFILE to meet your specific needs

PORT - Port of the "management" OpenVPN interface.
KILLTIME - Number of seconds where it should kill a VPN session, default is 12 hours.
TMPFILE - A temporary file used to parse the connected users

  • Add it to cron to run $x minutes/hours

echo '0 * * * * root /root/kill_vpn_clients.sh >> /var/log/kill_vpn_clients.log' > /etc/cron.d/kill_vpn_clients

About

Simple bash script to disconnect OpenVPN clients after a specific connected time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages