I have been trying to figure out how to use the suggestions you gave me, but I am not having any luck. What I would like to know how to do is to make a script that will run whenever a connection goes down and when that happens, it updates a text file that has the common name of each client and the accumulated bytes sent and received. Is this possible? Also, I would like to make a simple script that will restart a client connection if it has been connected for more that 24 hours. I am a beginner and I am willing to pay for working scripts that will work for me.
On 2/25/07, Roland Pope <rpope@xxxxxxxxxxxxx> wrote:
> Could you give me an example of a script? Would it be possible to just
> append the bytecount of a clients session to a text file, specifing the
> bytecount, name of client, and date appended? Also, how can I force a
> tunnel restart after 24 hours of straight connectivity?
I have attached a bash script I use to Update DNS and Radius.
It uses the CN of the tunnel user as the unique identifier, so you can't
be using the 'duplicate-cn' option or else things will behave weirdly.
I also use MRTG to graph the packets though the tun interface, but
that's only good for totals, not individual tunnel values.
I run this script on both up and down to get the START and STOP
accounting packets sent to radius as well as the add and delete of DNS
If you wanted to you could append the output to a text file instead of
sending it to radius.
To kill off a tunnel every X hours of uptime, make a cron job that uses
netcat to send a status command to the OpenVPN server managment
interface, work out what tunnel have been up for longer than X, then
sends a 'kill CN' command to the Common Name of that tunnel user.
Ie. echo 'status 2|nc 127.0.0.1
1194|grep CLIENT_LIST' will give you a
list of connected clients including the date that they connected.
You can then pull out the Common Name and the connected date, do some
date conversions and date arithmetic (I leave the actual coding to the
reader :) ), then kill off any CN's who have been connected for more
than X with a 'echo 'kill CN|nc 127.0.0.1 1194'
This all assumes your OpenVPN server has a management port listing on
port 1194 at localhost of course.
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
Openvpn-users mailing list