List which VPN clients are connected

You can do this with a small expect-script:

#!/usr/bin/expect
spawn telnet localhost 7505
set timeout 10
expect "OpenVPN Management Interface"
send "status 3\r"
expect "END"
send "exit\r"

And run it with (e.g.)
while true; do ./openVPNUserlist.sh |grep -e ^CLIENT_LIST; sleep 1; done

Also, in your server.conf - file, add the line
management localhost 7505

Packages you need to have installed:
telnet expect

Interestingly, the status does only update after a while (when a client disconnects, it keeps being displayed in the status for quite a while... Did not find a way to get around this yet :(
Change the timeout in your server.conf to the values you need:
keepalive 10 60
= ping client every 10 seconds and consider it disconnected after 1 minute.

Tags:

Openvpn