Community discussions

MikroTik App
 
cicserver
Member
Member
Topic Author
Posts: 303
Joined: Sun Jul 24, 2011 12:04 pm

quota limit with freeradius

Wed Mar 16, 2016 7:26 am

I have setup freeradius 2.x with mysql as Billing system and Mikrotik as NAS (pppoe server).

I have managed to configure few modules like time limit, expiration etc. but unable to configure volume QUOTA limit , e.g 100MB for user.

I tried to take various examples from the google/forum but none of it worked. can some one please post some working examples of the counters and tips please?
 
User avatar
aacable
Member
Member
Posts: 435
Joined: Wed Sep 17, 2008 11:58 am
Location: ISLAMIC Republic of PAKISTAN
Contact:

Re: quota limit with freeradius

Wed Mar 16, 2016 8:28 am

configure volume QUOTA limit , e.g 100MB for user.
I tried to take various examples from the google/forum but none of it worked. can some one please post some working examples of the counters and tips please?
Try following: [I have used it in Ubuntu Freeradius 2.x with Mikrotik 5.x]

QUOTA LIMIT FOR USER with CUSTOM MEANINGFUL REJECT REPLY MESSAGE


To limit user data volume limit (either daily, weekly or monthly, set this in reset section) use below code.

edit the file /etc/freeradius/sites-enabled/default

and add following under “authorize {“ section
totalbytecounter{
reject = 1
}
if(reject){
update reply {
Reply-Message := "ZAIB-RADIUS-REPLY - You have reached your bandwidth limit"
}
reject
}
now edit file /etc/freeradius/modules/sqlcounter_expire_on_login
Add Following
sqlcounter totalbytecounter {
counter-name = Mikrotik-Total-Limit
check-name = Mikrotik-Total-Limit
reply-name = Mikrotik-Total-Limit
sqlmod-inst = sql
key = User-Name
reset = never
query = "SELECT ((SUM(AcctInputOctets)+SUM(AcctOutputOctets))) FROM radacct WHERE UserName='%{%k}'"
}
Save and Exit.

Now add user attribute in radchceck table (Following is 1 MB total data limit example, which can be used in parts as well )

Note: Value is in bytes, so use it accordingly
INSERT INTO radcheck ( id , UserName , Attribute , op , Value ) VALUES (NULL , 'zaib', 'Mikrotik-Total-Limit', '=', '1000000');
Once the user quota over, and user retry login he will get access deny message, and in radius log, you can see following
radreply.PNG
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: BartoszP, bugacha, Elvis1991 and 35 guests