Tech News & Discounts

Sqlcounter bandwidth limit for Freeradius

1,807

To set bandwidth limits using Freeradius, we need to enable the sqlcounter module. It only works on freeradius setups that use sql. We did a tutorial on Radius with SQL here.

Radius is very easy to customize for your need. One basic use-case is the setting of monthly quotas for user.  In this guide I’m going to show you how to do just that, but using this structure you can create any accounting criteria you want. The process is the same, using sqlcounter.

Let’s begin:
[crayon-5d1295bf0c2c0739099688/] Next, we need to create our custom attribute. Edit the sqlcounter file and add your attribute
[crayon-5d1295bf0c2cd856048854/] After defining your attribute, add the sqlcounter in “sites-enabled/default” config file, under the authorize settings.
[crayon-5d1295bf0c2d2152479508/]  

In order to test freshly created bandwidth limitation, assign the attribute to an user. You can insert it directly into the SQL database or use the web panel we installed in the Freeradius SQL + Daloradius .

Go the the panel, add a new user. Click on the attributes tab and select Custom Attribute. I’ve added the name of the attribute that I used in the sqlcounter file, “Max-Bandwidth”. Set the limit value you want. Mine is aroud 3.5GB for this example.

Set the operator to ” :=” and the Target to “reply”.

sqlcounter freeradius

 

 

Common sqlcounter errors

Sometimes things don’t go as expected. Please leave a comment with the error you got and I’ll try to help, or if you managed to fix it, please leave a comment with the fix for the issue.  Here are some that I got while trying to figure this one out.

“Failed to create the pair: Unknown name” 

Cause 1. You forgot the add the sqlcounter (total_bandwidth) name in the “default” settings file.

Cause 2. You forgot to link to the sqlcounter file (see the first instruction – the one with “ln”)

“Reference “${modules.sql.dialect}” not found” 

This may not be your fault. It is probably a Freeradius bug but you can workaround it by hardcoding the dialect in sqlcounter to mysql, or whatever database you’re using.
[crayon-5d1295bf0c2dd556190852/] If the user can’t connect or can connect regardless of the Bandwidth attribute value, make sure to set the Attribute as a Reply attribute and the Operator to ” :=”

 

You might also like
Comments
Loading...