[pptp-server] Scripts

George Vieira GeorgeV at citadelcomputer.com.au
Wed Aug 15 00:49:20 CDT 2001


I sent a script close to a month ago that did this.. buggered if it's in the
archives or even in my Sent Folder...
 
What I did is detect the PPP0 or PPP1 ,etc session that it's running from
and search it's PID. The Parent PID is the pptp control that started the
PPPD session in the ps -ef | grep $PPID contains the IP address of the real
IP. This you wil have to `cut` out..
 
 
 
Aha!!! Lucky.. I found my original reply to the list..
----------------------------------------------------------------------------
------------------------
 
I know a cheat way is to read the PPPx device in ip-up.local and then find
it's parent process of the pppd command this then contains the real IP and
is fully legit... eg.

ps -ef (eg, to show where to find the real IP )

---------------

root 5104 1111 0 23:34 ? 00:00:01 pptpd [144.137.66.4]

root 5105 5104 0 23:34 ? 00:00:00 /usr/sbin/pppd local file
/etc/ppp/options.pptp 115200

 

cat /var/run/ppp0.pid (You get "ppp0" as $1 in ip-up.local )

---------------------

5105

if-up.local

-----------------

# interface-name tty-device speed local-IP-address remote-IP-address ipparam

PID=`ps -fp \`cat /var/run/$1.pid\` | tail -1`

RPID=`echo $PID | cut -f 3 -d " "`

IP=`ps -p $RPID -o cmd | tail -1 | cut -f 2 -d "[" | cut -f 1 -d "]"`

echo "Real IP Connection : $IP " >> /var/log/pptp.log

 

PLEASE someone find a cleaner way of doing this.. this works for me
everytime but when 100 connection come in at once I bet the CPU must go
bonkas with shell scripting....

 

 

Hope this helps the idea a bit... maybe someone can write a C code version
which compile would be passed something like "pptpip ppp0" and it'll return
the IP... Oh cool yeah!!..

 

thanks,
George Vieira
Network Engineer
Citadel Computer Systems P/L
PH +(61)2 9955 2644
FX +(61)2 9955 2659 

 
-----Original Message-----
From: Tomer Okavi [mailto:tomer at netop.co.il]
Sent: Wednesday, August 15, 2001 4:39 PM
To: 'PPTP LIST'
Subject: [pptp-server] Scripts



Hey all.

 

I made a simple script to notify by e-mail when a user has connected to the
VPN box

I'm running it through /etc/ppp/ip-up.local.

Now, I would like to get the remote "real" ip address, (from where the user
has connected).

I could not find anything like that in man pppd etc.

Is there a way of accomplishing this without tail,grep the logs?

 

Thanks.

 

Tomer




More information about the pptp-server mailing list