How to get client IP address/target port in python code

Dmitriy Golubev golubev.dmitriy at
Wed May 8 14:29:11 CEST 2019

Alan, good day!

Thank you for your reply. When I post this question I found 2 things:
1. This code working:
  update request {
                &Packet-Src-IP-Address = "%{Packet-Src-IP-Address}"
                &Packet-Dst-Port = "%{Packet-Dst-Port}"
Is it correct? In your code I see that you don't use '&', don't expand
attribute value and use fake attribute name instead of real one. I am
not expert in unlang, can you explain these differences?

2. 'preprocess' module add NAS-IP-Address and populate it with Client
IP address in case if it was not filed by RADIUS client. This behavior
is ok for me.


On Wed, May 8, 2019 at 1:30 PM Alan DeKok <aland at> wrote:
> On May 8, 2019, at 5:37 AM, Dmitriy Golubev <golubev.dmitriy at> wrote:
> >
> > I use rlm_python plugin to add custom logic to the Freeradius.
> > For logging purposes I want to know client IP address and target port.
> > I check source code of freeradius and found that its possible to
> > obtain this information from request structure. However I can't find
> > how to get it from python code.
>   The attributes are "virtual" in that you can reference them, but they're not in any list.
>   The fix is simple: make them real.
>         update request {
>                 Tmp-IP-Address-0 := Packet-Src-IP-Address
>                 ...
>         }
>   See Packet Src / Dst IP-Address / Port.
>   Alan DeKok.
> -
> List info/subscribe/unsubscribe? See

More information about the Freeradius-Users mailing list