I've configured my PPTP server to automatic assign IP's for the clients.
I'm interested in know what's the current local IP assigned to an specific user. I actually have an script to determine the remote IP but actually I'm not finding the way to find the LAN IP.
That's a sample line in the CHAP file, as you can see, the IP is auto-assigned:
test pptpd 0802928d37e151f338696d1601040570 *
Thanks!
I was reading little bit more (few days later) and there's a PPTP "database" that you can use to do that.
The code below:
#!/usr/bin/perl -w
@line = `/usr/bin/tdbdump /var/run/pppd2.tdb |grep "PEERNAME="`;
foreach $user (@line) {
chomp ($user);
undef $name;
undef $iplocal;
@record = split (/\;/, $user);
foreach $field (@record) {
if ($field =~ /PEERNAME/) {
$field =~ s/PEERNAME\=//gi;
$name = $field;
}
if ($field =~ /IPREMOTE/) {
$field =~ s/IPREMOTE\=//gi;
$field =~ s/(.*)\\.*/$1/gi;
$iplocal = $field;
}
}
if ((defined $name) && (defined $iplocal)) {
print ("$iplocal $name\n");
}
}
I copied the script /usr/bin to run it easy. The sample output will be like that:
root@localhost:~# wppp
192.168.0.128 test
I hope it help somebody :)