Is it possible to automate a Disconnect-Request based on exceeded Monthly-Usage?

Houman houmie at gmail.com
Wed Sep 11 20:15:42 CEST 2019


Hi Alan,

Alright, let's go through the steps.

1) Based on sites-available/originate-coa I have inserted the following
into /etc/freeradius/3.0/sites-enabled/default

I have added the home_server after the server default like this:

server default {
   ...
}
home_server example-coa {
        type = coa
        ipaddr = 127.0.0.1
        port = 3799
        secret = secret123
        coa {
                irt = 2
                mrt = 16
                mrc = 5
                mrd = 30
        }
}

Looking at "man unlang", In the server default I have added this section to
the preacct:

preacct {
        preprocess
        if (Monthly-Usage > 300000000000) {
                update coa {
                        &User-Name = "%{User-Name}"
                        &Acct-Session-Id = "%{Acct-Session-Id}"
                        &NAS-IP-Address = "%{NAS-IP-Address}"
                }
        }

This should now send the Disconnect-Request, based on the usage greater
than 300 GB.

Does this make sense what I have done so far?

Thanks,
Houman






On Wed, 11 Sep 2019 at 12:15, Alan DeKok <aland at deployingradius.com> wrote:

> On Sep 11, 2019, at 3:05 AM, Houman <houmie at gmail.com> wrote:
> >
> > Sorry, I should have explained that I'm using StrongSwan as my NAS, which
> > is supporting CoA :
>
>   That's nice, but sort of assumed.  If the NAS doesn't support CoA, then
> there's no point in sending it CoA packets.
>
> > I have found the home server example in sites-available/originate-coa. I
> > think I have to set it up under /etc/freeradius/3.0/proxy.cnf.
>
>   I'm not sure what that means.  Set "it" up?  Set *what* up?
>
>   If you read the "originate-coa" virtual server, you will see what you
> have to set up.  So did you do that?
>
> > Alan, I'm a bit lost here when you said:
> >
> >> That's what "originate-com" is for.
> >> The documentation isn't perfect, but it should be good.  When you
> receive
> > an accounting >request packet, check for over the limit, and if so, send
> a
> > Disconnect-Request packet.
> >
> > I think you mean I have to do that
> > in /etc/freeradius/3.0/sites-enabled/default under the section:
> >
> > update request { ... }
>
>   In the "preacct" or "accounting" sections.
>
> > In what programming language do I have to do that? I think it has to be
> in
> > SQL right?
>
>   If your users are in SQL, you check their usage via SQL queries.
>
> > I already do this to capture the monthly usage upon each request:
> >
> > update request {
> >
> >                Monthly-Usage = "%{sql:SELECT
> > COALESCE((SUM(`acctoutputoctets`)), 0) FROM radacct WHERE
> > `username`='%{User-Name}' AND Month(acctupdatetime)=(Month(NOW())) AND
> > Year(acctupdatetime)=Year(NOW())}"
> >
> >        }
>
>   OK.
>
> > Now I need to add another line underneath to compare the Monthly-Usage
> > against a value and then send the Disconnect-Request if it's greater than
> > the value.  How Do I raise the Disconnect-Request?
>
>   The "originate-coa" virtual server explains that in detail.  Read the
> comments at the top of that file.  See also "man unlang".
>
>   There *is* extensive documentation on this, that I already pointed you
> to.  If you have questions about the documentation, ask.  But asking a
> question *answered in the documentation*, then it looks like you haven't
> read it.
>
>   Alan DeKok.
>
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html


More information about the Freeradius-Users mailing list