Accounting-Request Re write Rule
Nathan Ward
lists+freeradius at daork.net
Thu Oct 25 00:38:33 CEST 2018
> On 25/10/2018, at 9:51 AM, Maile Halatuituia <maile.halatuituia at tcc.to> wrote:
>
> Hi
> I need to rewrite this attribute Cisco-AVPair = "acct-input-octets-ipv6=xxx" upon receiving it in the accounting request from my BRAS to my Radius Server so I can further process.
>
> I received this Cisco-AVPair = "acct-input-octets-ipv6=xxx"
>
> I have done this on the Radius Server /etc/freeradius/sites-available/default
>
> if( &Cisco-AVPair[*]=~/\(acct-input-octets-ipv6\)=\(\d+)/ ) {
> update request {
> &acct-input-octets-ipv6 := "%{2}"
> }
> }
This won’t work as acct-input-octets-ipv6 is not a standard RADIUS attribute. It is text as the value of a Cisco-AVPair attribute.
You will need to define this attribute if you want to be able to use it in your FreeRADIUS config.
> But I have this on my debug
>
> if ( &Cisco-AVPair[*]=~/\(acct-input-octets-ipv6\)=\(\d+)/ ) {
>
> (0) if ( &Cisco-AVPair[*]=~/\(acct-input-octets-ipv6\)=\(\d+)/ ) -> FALSE
>
Your regex is not correct. You are not escaping the trailing ), which I presume you need to do. You can test this regex with standard regex tools - you should make sure your regex is correct and matches examples you feed it. There are a bunch of “online” regex testers, if you don’t have other ways of doing this.
I don’t think you should have brackets around the acct-input-octets-ipv6 either - you are not extracting this text. You should only have brackets around the part you wish to capture (i.e. the \d), and then use %{1} not %{2}.
> Not sure if I can read it correctly but seem the rule does not matched ..
> Appreciate anyone comments if didn't do it correctly
More information about the Freeradius-Users
mailing list