Openvpn Web Status Php

This is a pretty simple PHP script that allows you to access your (OpenVPN-based) VPN status (such as connected hosts, received/transferred bytes, etc) through a web page. It fetches the information using OpenVPN management console and displays it in a web-friendly way.

Installation is straightforward:

  1. Download the script (see link below), rename it, and place it in a web accessible location. Example:
/var/www/vpnstatus.php
  1. Enable OpenVPN management console (if you haven't already done so) adding the following line to the OpenVPN configuration file:
management localhost 7505
  1. Restart OpenVPN

That's it!. Just access http://yourhost/vpnstatus.php to see your VPN status in a web-friendly way.

This instructions assume you'll place the script on the same machine running OpenVPN. Otherwise, you'll have to edit the script and modifiy it accordingly (changing the localhost to the name of your OpenVPN host) and also change the management option in your OpenVPN configuration to listen in other addresses.

Download the script here: vpnstatus.txt. Don't forget to rename it to a .php extension.

21 responses

If my OpenVPN management interface needs a password to access, while line should I add the password to?

Very nice Script! I was searching for such a script for days! You saved my day!


THX!

Thank you for sharing the vpnstatus page script. I was looking for quite a while for something like this. It took me only a few minutes to have this working including password handling. Much appreciated.
please help me for this

i get error

Connection timed out (110)

Can "management localhost <port> be included in my server.conf using udp connection? Coz Ive used this great script before and it crashed my servers. Also I have never seen anyone using this on udp settings, jut tcp configurations. Hope you can answer my questions asap. Thanks for a great script.:)
Hello,
tried using the script, but the output is always empty (the raw page is generated, but no clients are listed).

my management console is working (tested via telnet).

debug variable do not ouput anything:

what could be the error?

sample output from telnet:

Escape character is '^]'.
>INFO:OpenVPN Management Interface Version 1 -- type 'help' for more info
status
TITLE,OpenVPN 2.1_rc11 i486-pc-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] built on Sep 18 2008
TIME,Thu Oct 20 19:32:51 2011,1319131971
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t)
CLIENT_LIST,xxx,192.168.5.201:44388,10.10.0.26,16211,17386,Thu Oct 20 18:53:28 2011,1319129608
CLIENT_LIST,xxxx,10.0.0.1:49658,10.10.0.6,692609,840687,Thu Oct 20 18:51:41 2011,1319129501
CLIENT_LIST,xxx,xxx.xx.10.144:50863,10.10.0.42,16101,17360,Thu Oct 20 18:53:26 2011,1319129606
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
ROUTING_TABLE,10.10.0.26,rtorrent,192.168.5.201:44388,Thu Oct 20 18:53:28 2011,1319129608
ROUTING_TABLE,10.10.0.42,grabher,xxx.xxx.10.144:50863,Thu Oct 20 18:53:27 2011,1319129607
ROUTING_TABLE,10.10.0.6,haemmy,10.0.0.1:49658,Thu Oct 20 19:32:51 2011,1319131971
GLOBAL_STATS,Max bcast/mcast queue length,0
END

In my opinion, vpn ninja is the best!! the website is www.vpnninja.com
Try free vpn at versavpn.com. We have fast servers. Port forwarding enabled also.
Hi, do you also have a gui to manage the users who can access openVPN?
Cool! Thank you for sharing this script. Been looking for something like this for hours.
Thanks - works a treat !
GREAT WORK, THX A LOT !!
Works great!
Is there a way to use status version 2?
WOOOW!! pecfect!it works perfect!!, now I willl try to get more information using this "management" socket.
Very nice, works great. Thanks for sharing the php script.
Do you have a script for list users in ssh?

Thx TaToosh

Is this still available? The download link above is 404'd. Thanks!
i'm not able to download your scripts, could you share it again?
Sorry but the link is down. Could you repost your script ? :S
Since the link is down, I made a copy of it on pastebin http://pastebin.com/U9SESPB0
screenshot please ? even redacted
the pastebin is still working. Also, replace split with explode if using php 7.0