Community discussions

MikroTik App
 
spire2z
Long time Member
Long time Member
Topic Author
Posts: 516
Joined: Mon Feb 14, 2005 2:48 am

Gigs useage limit via radius with top up etc finally!!

Tue Nov 18, 2008 1:38 pm

I have finally finished a Freeradius based usage limiter with a PHP frontend for paypal payments for use with MT. Users can signup, login and buy Gigs, top up etc from a PHP interface and paypal and mysql database. The radius server can take any data limit and have a monthly limit and a top up bank. Oh and it dosen't use rlm_sqlcounter ;)

It uses dynamic encrypted paypal buttons. The backend is secure and only adds credit once payment is completed.

It has taken me goddamn ages to develop this so I can offer it for sale if anyone is interested :) contact me here.. or at turboweb.org
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Gigs useage limit via radius with top up etc finally!!

Wed Nov 19, 2008 7:07 am

Good job, we've done a similar thing when we created our hotspot system :-)

Australian users are all limited by data/speed/time so we had to incorporate all 3 into a system that works with mikrotik and can be customised to work with other radius supporting clients. Tis fun :-D
 
spire2z
Long time Member
Long time Member
Topic Author
Posts: 516
Joined: Mon Feb 14, 2005 2:48 am

Re: Gigs useage limit via radius with top up etc finally!!

Wed Nov 19, 2008 1:10 pm

Yeah mine is similar to usermanager but with data instead of time purchased. The biggest problem I had was freeradius 2 gig limit on radius replys, but thats sorted now ;)
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Gigs useage limit via radius with top up etc finally!!

Sun Jan 04, 2009 5:23 pm

Yeah, if you had've mentioned earlier.. all you need do is setup a gigaword value for your radius dictionary :-P

Which I think mikrotik already supplied (looks around) uhh here - http://www.mikrotik.com/Documentation/m ... dictionary
 
spire2z
Long time Member
Long time Member
Topic Author
Posts: 516
Joined: Mon Feb 14, 2005 2:48 am

Re: Gigs useage limit via radius with top up etc finally!!

Mon Jan 05, 2009 7:29 pm

Well your idea will work with accounting and if you use a script to redirect users on each router from the accounting. But we wanted a fully RADIUS based setup so and NAS can use it with PPPoE and Hotspot from any of our AP's with no scrpits. Also we wanted an industry standard solution.

You did know that rlm_sqlcounter cant send a gigawords value so you cant actually do it. Also rlm_sqlcounter cant even read a number from the database higher than 4gb so we had to come up with a better idea for monthly limits. Maybe your using a different radius server?

Our current way now can have any gigs value that is reset monthly and we also have another bank for topups and additional purchases that does not reset. So for example a user can have a 40GB monthly limit, but any additional data purchased will not be reset and will carry over if unused.

Cheers
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Gigs useage limit via radius with top up etc finally!!

Wed Jan 07, 2009 4:44 am

We have that working fine with an external radius (based on a modified version of freeRADIUS) and our own hotspot system, requires no extra scripting on the mikrotik side, just a redirect to our external login page. No we don't use rlm_sqlcounter either ;-) sorry if I wasn't clear on this in the previous post.

We also can take IP accounting to refund free site usage and as a secondary confirmation that all radius data is correct (if someone is disputing their usage etc)

If you wanna email me sometime I'm sure we could benefit through sharing of ideas. ( andrew [ at ] accessplus [ dot ] com [ dot ] au )
 
Beone
Trainer
Trainer
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Re: Gigs useage limit via radius with top up etc finally!!

Sat Apr 02, 2011 3:09 pm

No we don't use rlm_sqlcounter either ;-)
I know this thread is old, but I still take my changes :-)
If you don't use sql counter, you use some kind of PoD to disconnect users on reached datalimit, right?
Now, my question, how do you trigger the PoD? Or do you still use another way? Can you provide me with some info/hints?

We use sql counter now, but have problems with remaining data limits +4GB (wrapping counter).
In a perfect world sqlcounter would reply gigawords as well, but it doesn't.
We could patch the counter to make it reply 4GB -1 octet in case the left quota > 4GB, but it isn't perfect.
Very curious on your solution if you're willing to share, tnx.
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Gigs useage limit via radius with top up etc finally!!

Mon Apr 04, 2011 8:13 pm

You can write your own interface between radius => mysql that allows regular counting of gigawords, that's not an issue.
Just take your data field and calculate what you need to break it down into.

You can also use CoA or Disconnect packets so long as you've told the Mikrotik to accept incoming radius packets.
 
Beone
Trainer
Trainer
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Re: Gigs useage limit via radius with top up etc finally!!

Wed Apr 06, 2011 6:28 pm

You can write your own interface between radius => mysql that allows regular counting of gigawords, that's not an issue.
Just take your data field and calculate what you need to break it down into.

You can also use CoA or Disconnect packets so long as you've told the Mikrotik to accept incoming radius packets.
The accounting in the database itself is not the problem.
The problem is the reply of sqlcounter if the remaining datavolume for a user is > 4GB. Default freeradius doesn't reply gigawords from sqlcounter also, it just wraps the counter.
Yes, I could forget sqlcounter and use Disconnect packets to logout a user, but how do you trigger that for +5000 users?
I mean, how do you check your users reached their datalimit and send the disconnect packet if this happens?
Some script running in a cron checking all your users every x-minutes? How about server load?

Tnx
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Gigs useage limit via radius with top up etc finally!!

Tue Apr 12, 2011 3:28 pm

Not at all to be honest. The only reason we need to use PoD at the moment is if a user has left themselves logged in on another computer and/or kiosk computer.

The code for calculating gigawords and remaning data to send through as values to the mikrotik is really quite simple.

Here's a subset of the code used in a perl radius module:
my $xmit_limit = $prepaid % '4294967295';
my $xmit_limit_gigawords = int $prepaid / '4294967295';
...
('$user_name', 'Mikrotik-Xmit-Limit', '+=', $xmit_limit),
('$user_name', 'Mikrotik-Xmit-Limit-Gigawords', '+=', $xmit_limit_gigawords)"
and another example I found online:

http://www.open.com.au/pipermail/radiat ... 10966.html
 
Beone
Trainer
Trainer
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Re: Gigs useage limit via radius with top up etc finally!!

Thu Apr 14, 2011 8:24 pm

Ah ok, you use rlm_perl, that explains a lot ;-) We need to logout users on datacap reached.
Anyway, we found a solution in the meantime, tnx for your replies.
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Gigs useage limit via radius with top up etc finally!!

Fri Apr 15, 2011 7:20 am

That option does allow logout on data cap reached, it hands the max limit values on initial login.
Alternatively we also use CoA and CD radius packets to process user initiated disconnects.
 
Beone
Trainer
Trainer
Posts: 250
Joined: Fri Feb 11, 2011 1:11 pm

Re: Gigs useage limit via radius with top up etc finally!!

Fri Apr 15, 2011 10:04 pm

That option does allow logout on data cap reached, it hands the max limit values on initial login.
Alternatively we also use CoA and CD radius packets to process user initiated disconnects.
Yes I understand, your perl script acts the same way as sqlcounter but handles/replies gigawords correctly.
If we need to manually logout a user (doesn't happen much) we just do it from the nas cli, but indeed, being able to do it from the main radius frontend is more nice and easy.

Who is online

Users browsing this forum: Bing [Bot] and 99 guests