Celeb Glow
general | March 10, 2026

List which VPN clients are connected

Situation: I have a private VPN server at home which is open to the internet so that a certain group of people can connect to it (only keypair authentication is allowed).

How can I see which clients are currently connected to my VPN server?

I already tried to ping the hosts but it seems like some (actually most of them) block ICMP requests, so this fails always. Of course, I could examine /etc/openvpn/openvpn.log every time but this is not very convenient and definitely not suitable for a status report sent via email to me.

Remark: I'm using OpenVPN 2.2.1 x86_64-linux-gnu.

4 Answers

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.

I located extensive vpn logs in this folder:

ls /var/log/openvpn/

For me, there were two files there, named kind of like this:

Arbitary-Name-VPN.log
status-Arbitary-Name-VPN.log

The first file showed a log of all vpn connections that have happened over time, and the second one (status-...) showed who is connected right now.

The easy way is:

  • Add

    status /var/log/openvpn-status.log

    in your /etc/openvpn/server.conf and restart vpn server.

  • Use the below command to view connected clients from the log.

    while true;
    do cat /var/log/openvpn-status.log | sed -n '/OpenVPN CLIENT LIST/,/ROUTING TABLE/p' | tail -n+4 | sed "s/ROUTING TABLE//g"; sleep 4s;
    done

    This will update the client list every 3 seconds.

If you want it done in a single bash script, I took @GoodbyeKitty answer and made a single script..

#!/bin/bash
function management_server() { /usr/bin/expect <(cat << EOF
spawn telnet localhost 7505
set timeout 10
expect "OpenVPN Management Interface"
send "status 3\r"
expect "END"
send "exit\r"
EOF
)
}
while true echo "Checking IPs" do management_server | grep -e ^CLIENT_LIST sleep 30
done

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy