How to receive a mail on client connection and disconnecti ?

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
infomax
OpenVpn Newbie
Posts: 4
Joined: Wed Apr 20, 2011 7:49 am

How to receive a mail on client connection and disconnecti ?

Post by infomax » Wed Apr 20, 2011 7:54 am

Hi, i see we can use script, so we would like to receive a mail when a client is connecting to our server, and when he lost the connection?

Can we do that and how?

We are using openvpon 2.1.0 on Linux.

thanks

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: How to receive a mail on client connection and disconnec

Post by janjust » Wed Apr 20, 2011 8:26 am

Use a 'client-connect' and 'client-disconnect' script. The script would do something like

Code: Select all

#!/bin/bash
echo "$script_type $common_name" | mail someuser@somehost

infomax
OpenVpn Newbie
Posts: 4
Joined: Wed Apr 20, 2011 7:49 am

Re: How to receive a mail on client connection and disconnec

Post by infomax » Wed Apr 20, 2011 8:46 am

thanks, bu how do i use it? where do i put it?

thanks

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: How to receive a mail on client connection and disconnec

Post by janjust » Wed Apr 20, 2011 9:08 am

some work on your part is required: read the HOWTO and manual page, or buy my book and read chapter 6 ;)

infomax
OpenVpn Newbie
Posts: 4
Joined: Wed Apr 20, 2011 7:49 am

Re: How to receive a mail on client connection and disconnec

Post by infomax » Wed Apr 20, 2011 9:15 am

haa okay thanks.i will try this.

eric66300
OpenVPN Power User
Posts: 57
Joined: Fri Apr 15, 2011 12:05 pm

Re: How to receive a mail on client connection and disconnec

Post by eric66300 » Sat Apr 23, 2011 8:35 am

#!/bin/bash
echo "$script_type $common_name" | mail someuser@somehost
where can i put that code?

sorry noob question

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: How to receive a mail on client connection and disconnec

Post by janjust » Sun Apr 24, 2011 11:52 pm

use a 'client-connect' script on the server side. Read the manual page or buy my book and read chapter 6 ;)

infomax
OpenVpn Newbie
Posts: 4
Joined: Wed Apr 20, 2011 7:49 am

Re: How to receive a mail on client connection and disconnec

Post by infomax » Tue Apr 26, 2011 9:33 am

hi janjust, thanks a loy, it works like a charm :D

Post Reply