Using unlang for Calling-Station-Id

Kanwar Ranbir Sandhu m3freak at thesandhufamily.ca
Sat Sep 12 16:50:57 CEST 2009


Hello Everyone,

I want to use unlang to trim the Calling-Station-Id coming from the NAS
to only include the MAC address.  I know what to do, and how to write
the unlang lines.  But, I'm not sure where those lines should go.

At the moment, I put them in my virtual server's "preacct" section, like
so (ugly wrapping):

preacct {
  preprocess
     if (Calling-Station-Id =~ /(pppoe )([0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f])(.)/) {
        update request {
          Calling-Station-Id := "%{2}"
        }
     }
  acct_unique
  suffix
}



(yes, I could probably optimize the regex)

As far as I can see, this is working.  The "callingstationid" field in
the radacct table now only contains the MAC address.  Interim accounting
updates appear to be updating the rows properly as well.  I don't see
any obvious problems.

Should I be putting the Calling-Station-Id rewriting in other sections
as well?  I was thinking perhaps the "authorization" and/or "post-auth"
sections should have it, too.

Thanks in advance.

Regards,

Ranbir


-- 
Kanwar Ranbir Sandhu
Linux 2.6.27.30-170.2.82.fc10.x86_64 x86_64 GNU/Linux 
10:41:48 up 6 days, 21:12, 4 users, load average: 0.81, 0.61, 0.51 





More information about the Freeradius-Users mailing list