Updating user's quota with every accounting request

Alan DeKok aland at deployingradius.com
Sun Feb 23 14:09:37 CET 2020

On Feb 23, 2020, at 10:34 AM, Adam Mohamed <adam.mohamed at hoopoe.digital> wrote:
> Here's my use case, I'm limiting quota on users but that only happens with
> the authorize section, but once the user is logged in, I don't get to run
> the authorize section again so what I would like to do is check for user's
> usage everytime he sends an accounting request.. I just want to do an SQL
> query to sum his acctinputoctets and acctoutputoctets and if its > specific
> attribute in a radgroupcheck row, the user should be rejected or EVEN
> better add something to the reply attributes that is being sent with the
> accounting request with the remaining quota he is allowed to use like
> ChilliSpot-Max-Total-Octets := remaining quota..

  Most NASes don't support sending attributes in an Accounting-Response packet.

> Just let me know how to write the queries and where if you know and I'd be
> so grateful, thanks in advance.

  The format of the queries depend on your SQL server, which you haven't said.  And no, we're not going to explain the syntax of your SQL server.  That's already documented... in the documentation for the SQL server you're using.  I suggest reading it.

  Once you have a query that works, you can just use it in FreeRADIUS:

	if ("%{sql:SELECT ...}" > ...) {

  The main difficult is that it's difficult to query the value of one particular attribute in the "radcheck" table.  You'll again have to figure out what that SQL query is.  And read the SQL documentation to see how to do this.

  The FreeRADIUS documentation describes how the server works, and how to configure it.  It does NOT include documentation on how to do every possible configuration.  That's too hard.  Instead, we rely on users reading documentation, and asking questions which can be answered.

  Alan DeKok.

More information about the Freeradius-Devel mailing list