Discussion:
Accounting-Request Re write Rule
Maile Halatuituia
2018-10-24 20:51:28 UTC
Permalink
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}"
}
}
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


Not sure if I can read it correctly but seem the rule does not matched ..
Appreciate anyone comments if didn't do it correctly


Confidentiality Notice: This email (including any attachment) is intended for internal use only. Any unauthorized use, dissemination or copying of the content is prohibited. If you are not the intended recipient and have received this e-mail in error, please notify the sender by email and delete this email and any attachment.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.
Nathan Ward
2018-10-24 22:38:33 UTC
Permalink
Post by Maile Halatuituia
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.
Post by Maile Halatuituia
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}.
Post by Maile Halatuituia
Not sure if I can read it correctly but seem the rule does not matched ..
Appreciate anyone comments if didn't do it correctly
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users
Maile Halatuituia
2018-10-25 03:17:19 UTC
Permalink
Hi Nathan
Thank you so much for the valuable info I will look in to it and feedback later

cheers

-----Original Message-----
From: Freeradius-Users <freeradius-users-bounces+maile.halatuituia=***@lists.freeradius.org> On Behalf Of Nathan Ward
Sent: Thursday, 25 October 2018 11:39 AM
To: FreeRadius users mailing list <freeradius-***@lists.freeradius.org>
Subject: Re: Accounting-Request Re write Rule
Post by Maile Halatuituia
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.
Post by Maile Halatuituia
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}.
Post by Maile Halatuituia
Not sure if I can read it correctly but seem the rule does not matched ..
Appreciate anyone comments if didn't do it correctly
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Confidentiality Notice: This email (including any attachment) is intended for internal use only. Any unauthorized use, dissemination or copying of the content is prohibited. If you are not the intended recipient and have received this e-mail in error, please notify the sender by email and delete this email and any attachment.
Confidentiality Notice: This email (including any attachment) is intended for internal use only. Any unauthorized use, dissemination or copying of the content is prohibited. If you are not the intended recipient and have received this e-mail in error, please notify the sender by email and delete this email and any attachment.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users
Loading...