Modifying accounting request with vendor-specific attribute

Alan DeKok aland at deployingradius.com
Wed Jan 17 21:23:34 UTC 2024


On Jan 17, 2024, at 4:11 PM, Kruz Gaffaney <GaffaneyK at rconnects.net> wrote:
> I've updated the policy to be the following;
> 
> custom_rewrite_calling_station_id {
>        update request {
>                Calling-Station-Id := &request:client-mac-address
>                }
>        }
> 
> Although now I'm running into a new error when running radius in debug;
> 
> /etc/raddb/policy.d/canonicalization[116]: Unknown attribute 'client-mac-address'

  i.e. you didn't see that attribute name show up in the debug output, but you put it into the "update" section anyways.

  It helps to follow instructions correctly.  It's also good to be familiar with how RADIUS works, and what it does.  i.e. what is an "attribute", versus the value for an attribute.

  When the server prints:

	User-Name = "foo"

  The "User-Name" string is the attribute name

  The "foo" string is the value of the User-Name attribute.

> ...
> (0) Received Accounting-Request Id 26 from 72.19.55.73:16444 to 216.155.208.69:1813 length 834

  This packet lists a bunch of attributes.  Which one needs to go into Calling-Station-ID?

  Let's read the debug output.

> (0)   Cisco-AVPair = "client-mac-address=5483.3a9a.f1d7"

  That seems relevant.  Except the attribute name isn't "client-mac-address", it's Cisco-AVPair.  This can be discovered by reading the debug output, and seeing what's there.

  So the problem statement is really:

a) find the Cisco-AVPair attribute

b) where the value contains client-mac-address

c) take text after the "=", and then

d) copy it to Calling-Station-Id.

  A methodical approach is likely to fix issues like this.  Trying random things, or inventing syntax is not likely to help.

  What you want do is to use a regular expression:

	if (Cisco-AVPair =~ /client-mac-address=(.*)/)  {
		update request {
			Calling-Station-Id = "%{1}"
		}
	}

  That's going to work.

  Alan DeKok.



More information about the Freeradius-Users mailing list