Copying User-Name from inner tunnel to outer for accounting
Hi, I am trying to do accounting for a user that previously authenticated through RADIUS. I know that the best way would be to use cui and have the NAS send a properly hashed identifier in its Accounting-Request, but unfortunately, my NAS does not support re-using the User-Name from the Access-Response for accounting. It always sends the anomymous identity from EAP instead. My idea was to save the authenticated user in the auth phase in inner tunnel, then extract this again when the accounting request comes in. However, I can't get this to work. What I tried is to set post-auth { update outer.session-state { User-Name := "%{User-Name}" } } in inner tunnel, then accounting { update request { User-Name := "%{session-state:User-Name}" } } in the outer config. HOwever, it always is empty that way. I verified that the NAS does correctly send the same Acct-Session-Id for both the auth ant the accounting requests, so FreeRADIUS should be able to correlate the state. The accounting request will ultimately be forwarded using the REST module. Can anyone explain how I could get this to work? Kind regards, Nik
On Jul 20, 2026, at 5:27 PM, Dominik George via Freeradius-Users <freeradius-users@lists.freeradius.org> wrote:
I am trying to do accounting for a user that previously authenticated through RADIUS. I know that the best way would be to use cui and have the NAS send a properly hashed identifier in its Accounting-Request, but unfortunately, my NAS does not support re-using the User-Name from the Access-Response for accounting. It always sends the anomymous identity from EAP instead.
Upgrade the NAS. :(
My idea was to save the authenticated user in the auth phase in inner tunnel, then extract this again when the accounting request comes in. However, I can't get this to work.
Save it *where*?
What I tried is to set
post-auth { update outer.session-state { User-Name := "%{User-Name}" } }
in inner tunnel, then
accounting { update request { User-Name := "%{session-state:User-Name}" } }
in the outer config. HOwever, it always is empty that way.
Yes. The session-state list is tracked only for Access-Request packets. If you want to store data across Access-Request to Accounting packets, put the information into a database.
I verified that the NAS does correctly send the same Acct-Session-Id for both the auth ant the accounting requests, so FreeRADIUS should be able to correlate the state.
The session-state list in FreeRADIUS has nothing to do with the Acct-Session-ID attribute.
The accounting request will ultimately be forwarded using the REST module.
Can anyone explain how I could get this to work?
In post-auth, save the User-Name information in a database, keyed by Acct-Session-Id. Then, update the "accounting" section to retrieve the User-Name from a database, keyed by Acct-Session-ID. Alan DeKok.
Hi Alan,
In post-auth, save the User-Name information in a database, keyed by Acct-Session-Id. Then, update the "accounting" section to retrieve the User-Name from a database, keyed by Acct-Session-ID. 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? Thanks, Nik
On Jul 20, 2026, at 6:17 PM, Dominik George <nik@naturalnet.de> wrote:
In post-auth, save the User-Name information in a database, keyed by Acct-Session-Id. Then, update the "accounting" section to retrieve the User-Name from a database, keyed by Acct-Session-ID. 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.
If only there was some kind of debugging output which would show you what the server is doing.
Do you happen to have an example somewhere of how to use the cache module for such a short-term storage?
Read the debug output. It will tell you what's going on. Alan DeKok.
Alan,
If only there was some kind of debugging output which would show you what the server is doing.
If only there were less condescending and more helpful people on this mailing list.
Read the debug output. It will tell you what's going on
Seriously, if that had helped, I'd not have gone through the pain to ask here. -nik
On Jul 20, 2026, at 9:06 PM, Dominik George <nik@naturalnet.de> wrote:
If only there were less condescending and more helpful people on this mailing list.
I've already helped you, with documentation that you insisted on ignoring. When you join the list, the automated messages / help text tells you to post the debug output to the list. Yet you didn't do that. Why? Is it beneath you to follow instructions? Do you think that the documentation is lying to you about how to solve problems? I shouldn't be surprised after 25+ years of this. Some people think that the rules don't apply to them.
Read the debug output. It will tell you what's going on
Seriously, if that had helped, I'd not have gone through the pain to ask here.
a) post the debug to the list as ALL of the documentation says. b) keep complaining how mean I am for telling you to follow the documentation. Pick one. Hint: one response will get the problem solved. The other response will get you banned from the list. Alan DeKok.
Dominik George via Freeradius-Users <freeradius-users@lists.freeradius.org> writes:
If only there were less condescending and more helpful people on this mailing list.
There are two things about this list which makes it exceptional among all similar open source project user lists I read: 1) the ever-present and extremely helpful core developers 2) the number of users demonstrating a complete inability to read and follow the simple and well documented problem reporting instructions It has been like that for decades. I can't explain either. But I am really grateful that the second hasn't affected the first. I have sometimes wondered what makes FreeRADIUS users extra dense, It kind of hurts, since I must admit being a FreeRADIUS user myself. Most other user groups understand that requests for more information *is* help. But FreeRADIUS users often take it as an insult, and do their best to confuse the issue instead. Why? It's like they don't want any help. They just want to complain. Which I guess is their right. There are just better places than a public mailing list for that. Maybe try shouting at a wall instead? Bjørn
Most other user groups understand that requests for more information *is* help.
I also understand that. However, Alan did *not* request more information. He told me to solve my problem alone with the debug output and his documentation (which is, to put it mildly, not an example for project documentation that actually helps understanding the software). I tried that approach for 6 hours before asking for help. I'd happily provide any debug information there is, if I had the tiniest idea of what to look out for. Alan could have provided such a hint and asked for the specific output after I explained that I have not a real idea where to start, instead of spitting out insults and very much *not* asking for specific debug output. I would have understood that. -nik
On 21/07/2026 13:36, Dominik George via Freeradius-Users wrote:
I'd happily provide any debug information there is, if I had the tiniest idea of what to look out for.
You should have received a link to this when you subscribed to the list: https://wiki.freeradius.org/guide/Users-Mailing-List There's no need to try and look out for the right bit of debug output to send. People nearly always send what they think is useful, which often isn't (or not complete enough), and then we get annoyed about not having the right information to be able to help. This happens a lot, hence the rapid descent into frustration. Post *everything* as explained in the link above, and then people will look through it and usually give a quick answer. (If you're not comfortable with that, e.g. especially it's a live system, then either replicate the problem on a test system or skim through and remove any sensitive info first, noting this might affect the ability to help.) -- Matthew
Matthew Newton via Freeradius-Users <freeradius-users@lists.freeradius.org> wrote:
There's no need to try and look out for the right bit of debug output to send. People nearly always send what they think is useful, which often isn't (or not complete enough), and then we get annoyed about not having the right information to be able to help. This happens a lot, hence the rapid descent into frustration.
I think there are two factors that keep people from doing so, and both share the same root cause: the debug information is usually an immense really ugly looking thing that A) they would not normally post on a discussion/chat for fear of being "messy", and most people these days grew up with discussions/chats so they view a mailing list through that lens and B) Is full of details about what is most often a component of security infrastructure, where there is a concern about exposure requiring them to consider how to redact some details, some of which may not be amenable to a simple search/replace. Some sort of interactive post-processor for the debug input to pretty it up, clean out the true cruft, perform redactions/aliasing on any exposed server names or addresses, and maybe point out a few common issues if it sees them... might be a worthwhile endeavor.
On Jul 21, 2026, at 3:40 PM, Brian Julin <BJulin@clarku.edu> wrote:
I think there are two factors that keep people from doing so, and both share the same root cause:
I'm not so sure. I think a major reason for not posting the debug output is a belief that it won't be helpful. * "I don't know which parts are relevant, so I didn't post it" * "I read it, and I didn't see anything that seemed relevant, so I didn't post it". The analogy here is someone having car trouble. No one has car trouble, and then tells their mechanic: * Hey, my car's acting funny. But I'm not going to tell you what's going on. You're the mechanic, you figure it out! * I brought my car in, but I'm not sure what you need to know. So I'm going to leave my car locked in the parking lot, and get angry when you tell me that you need to look under the hood.
the debug information is usually an immense really ugly looking thing that A) they would not normally post on a discussion/chat for fear of being "messy", and most people these days grew up with discussions/chats so they view a mailing list through that lens and B) Is full of details about what is most often a component of security infrastructure, where there is a concern about exposure requiring them to consider how to redact some details, some of which may not be amenable to a simple search/replace.
For (A), I would expect that people read the documentation which says "POST ALL OF THE DEBUG OUTPUT". Sadly, that expectant is often wrong. Even worse, I have no idea *where* we need to add more documentation, so that people will find it and read it. From what I can tell, there is a non-negligible set of people who have religious objections to reading documentation. For (B), I would expect that people be able to read the debug output for things they care about. e.g. secrets, IP addresses, etc. Even if you don't understand the output, it should be trivial to use "grep" to search for things. Or, people should be capable of setting up test accounts with fake names. But that don't happen, either.
Some sort of interactive post-processor for the debug input to pretty it up, clean out the true cruft, perform redactions/aliasing on any exposed server names or addresses, and maybe point out a few common issues if it sees them... might be a worthwhile endeavor.
That would be nice, but at this point no one is going to contribute it. The people who need it won't write it, and the people who don't need it are busy with other things. Alan DeKok.
On Jul 21, 2026, at 2:36 PM, Dominik George <nik@naturalnet.de> wrote:
However, Alan did *not* request more information.
The truth is, I did. I gave you instructions on what information to post. I gave you answers to all of the questions that you had in this message. I just did that in a documentation file that you refused to read. This list is for people who can read the documentation, and follow instructions. Since you've made it clear that you're not going to read documentation or follow instructions, I'll take the next step. You're now free to do whatever you want, somewhere else. Alan DeKok.
Dominik George via Freeradius-Users <freeradius-users@lists.freeradius.org> 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.
Dominik George via Freeradius-Users <freeradius-users@lists.freeradius.org> wrote:
My idea was to save the authenticated user in the auth phase in inner tunnel, then extract this again when the accounting request comes in. However, I can't get this to work.
As far as FreeRADIUS is concerned, the Authentication transaction and the Accounting transaction are two entirely different "sessions". Also, unless it is explicitly saved out by a module (like the TLS caching option for session resumption), "session-state" disappears after the authentication ends.
I verified that the NAS does correctly send the same Acct-Session-Id for both the auth ant the accounting requests, so FreeRADIUS should be able to correlate the state.
Yes but you'd need to use a module dedicated to doing so and call it where appropriate. Or, roll your own with rlm_cache, using the account session ID as the key and storing the desired username into the cache entry for that session when sending your Access-Accept, then retrieving it when receiving an Accounting Request. rlm_cache is, in general, a well tested and preferred internal mechanism for all such communication outside of the current session-state of a transaction. What you're looking to do is about maybe 15 lines of config/unlang. Takes a bit of time to wrap your head around the conventions for calling it though :-) - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (5)
-
Alan DeKok -
Bjørn Mork -
Brian Julin -
Dominik George -
Matthew Newton