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

Alan DeKok aland at
Wed Sep 11 23:39:33 CEST 2019

On Sep 11, 2019, at 2:15 PM, Houman <houmie at> wrote:
> 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:

  That works... but it's generally recommended to put home servers into proxy.conf.  That way you can find them later, as they're all in a consistent place.

> server default {
>   ...
> }
> home_server example-coa {
>        type = coa
>        ipaddr =

  Uh...  is your NAS on localhost?  Or is your NAS elsewhere in the network?

  You probably *don't* want to send CoA packets to FreeRADIUS.  As I explained before, this will NOT kick the user offline.

> 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}"
>                }
>        }

  That's good.

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

  No, it will send a "coa" packet.  Because you've used the word "coa".  If you want a disconnect, use "disconnect", as is documented in the originate-coa file I said to read, AND in "man unlang" I said to read.

> Does this make sense what I have done so far?

   Mostly.  See the comments above.

  And read the NAS documentation to see which attributes are needed in a Disconnect-Request packet.  We don't know which ones are relevant.  If you get the list wrong, then then the NAS will send a Disconnect-NAK response.  And won't tell you which attributes it was looking for.

  Alan DeKok.

More information about the Freeradius-Users mailing list