Re: [EXT] Re: Copying User-Name from inner tunnel to outer for accounting

Brian Julin <[email protected]> Mon, 20 Jul 2026 19:07:27 +0000
Newsgroups gmane.comp.freeradius.user
Message-ID <SJ0PR03MB70797B65410952FE72EEA167B4C32@SJ0PR03MB7079.namprd03.prod.outlook.com>
Dominik George via Freeradius-Users <[email protected]> wrote:
> I tried to do that using the cache module. I set
>   key = "%{Acct-Session-Id}"
> in the module config and then called
> 
>    post-auth {
>     cache
>  }
> in inner-tunnel, but that way, Acct-Session-Id expands to an empty string.
>
> Do you happen to have an example somewhere of how to use the cache
> module for such a short-term storage?

If your Acct-Session-Id is in the outer session and your username is in the inner session,
fist, get them into a variable of the same name, because in one case (Auth) your
variable is named "outer.request:Acct-Session-Id" and in the other just "Acct-Session-Id".  You
need the key = "%{whatever}" statement to always find the value at the same name,
(Or use a conditional expansion syntax there).

Pay attention in debug logs to which list attributes are in (control/request/reply/outer.request etc)

So copy outer:Acct_Session-Id into your inner tunnel request, then run the cache module:

update request {
  Acct-Session-Id := "%{outer.request:Acct-Session-Id}"
}
cache

(and set the ttl in the cache module definition to something short, unless you also need it for Interim/Stop packets)

Also, name your cache module.  You will probably end up needing more than one cache eventually for some other thing.

cache acctidcache {
   ttl = 30
   ...
}
(then call with "acctidcache" instead of "cache")

...or alternatively set key="%{%{Acct-SessionId}:-%{outer.request:Acct-Session-Id}}"
...if that syntax works there.  I've never tried that.

A handy trick for debug mode, if you need to see a variable that normal debug does not show you, is an empty if statement:

if ("foobar" == "%{Thing-I-Need-To-See}") {
}
the RHS expansion will then be verbosely logged under -X logging and you can search on "foobar" to find it quickly.
- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html