Re: get ip

James Cameron <[email protected]> Tue, 18 Mar 2014 08:26:39 +1100
Newsgroups gmane.network.poptop
Organization Netrek Vanilla Server Dictator
Message-ID <[email protected]>
On Sun, Mar 16, 2014 at 01:51:57PM -0500, Greg wrote:
> I was wondering if anyone could tell me how to get the ip address
> from the client when using ip_up notifier?
> 
> Also, with the ip_down notifier.

When given the --logwtmp argument, or the logwtmp option in
pptpd.conf, pptpd will add four arguments to the pppd command line:

    plugin /usr/lib/pptpd/pptpd-logwtmp.so pptpd-original-ip x.x.x.x

When pppd starts, the pptpd-logwtmp plugin will be activated, which
adds an options table, and notifiers for ip_up and ip_down.

When pppd processes arguments on the command line, it will fill in the
pptpd_original_ip variable in the plugin.

When the ip_up notifier is called, the pptpd_original_ip variable will
have the IP address of the client, or their NAT gateway.

(In the distributed source, ip_up calls logwtmp(3), and optionally
writes the details to the debug log.)

You can get the IP address from the pptpd_original_ip variable.

> I'm attempting to track the bandwidth usage and connection via the
> above notifiers.  Any help would be greatly appreciated.

Conventional UNIX wtmp accounting can be used for connection and time
spent, but not for data used.

Data used can be deduced by reading the byte counts at ip_down time,
which are part of the pppd implementation.

The byte counts against the PPP network interface will trend with the
byte counts of the PPTP stream; but if you need more exact network
accounting use iptables counters.

Bandwidth can be calculated by averaging data used over connection
time.

-- 
James Cameron
http://quozl.linux.org.au/

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech