Define New Attribute
Hello, I need to track some type of 'user group'. i´m doing this to not overload my database servers. into the radgroupreply table i need to 'create' one attribute like: Check-Bandwidth := [0,1] i added this attribute in groupreply, in my dictionary file and i can see this attribute in the 'authorization' section. How i can pass it to 'accouting' section ? maybe setting global variable for this session ? the purpose of doing this is to check if value is 1, freeradius need to track this user every interim-update, Start and Stop Packet-Type. if value is 0, freeradius skip this user from checking. ... this is the 'best' way ? if anyone has a better way.. and can share.. i´ll be thankful !! Regards, -- Sds. Alexandre Jeronimo Correa Sócio-Administrador Office: +55 34 3351 3077 Onda Internet www.onda.net.br
On 4 Dec 2012, at 20:50, "Alexandre J. Correa (Onda)" <alexandre@onda.net.br> wrote:
Hello,
I need to track some type of 'user group'. i´m doing this to not overload my database servers.
into the radgroupreply table i need to 'create' one attribute like:
Check-Bandwidth := [0,1]
i added this attribute in groupreply, in my dictionary file and i can see this attribute in the 'authorization' section.
How i can pass it to 'accouting' section ? maybe setting global variable for this session ?
Call sql.authorize in preacct. -Arran
Doesn´t work.. preacct { preproccess acct_unique suffix sql.authorize } accouting { if (Check-Quota == "1") { if (Acct-Status-Type == "Start") { onda_startquota } elsif (Acct-Status-Type == "Interim-Update") { onda_updatequota } } } Debug: # Executing section post-auth from file /etc/freeradius/sites-enabled/default Sending Access-Accept of id 128 to 192.168.2.200 port 38896 Framed-Compression := Van-Jacobson-TCP-IP Framed-MTU := 1492 Acct-Interim-Interval := 600 Framed-Protocol := PPP Mikrotik-Rate-Limit := "64k/64k" Check-Quota := 1 Finished request 0. Going to the next request Waking up in 4.9 seconds. rad_recv: Accounting-Request packet from host 192.168.2.200 port 55834, id=129, length=149 Service-Type = Framed-User Framed-Protocol = PPP NAS-Port = 11 NAS-Port-Type = Ethernet User-Name = "xande" Calling-Station-Id = "1C:75:08:21:91:30" Called-Station-Id = "pppoe-main" NAS-Port-Id = "ether2" Acct-Session-Id = "81400005" Framed-IP-Address = 10.55.0.255 Acct-Authentic = RADIUS Event-Timestamp = "Dec 5 2012 10:45:52 BRST" Acct-Status-Type = Start NAS-Identifier = "PPPOE-TESTE" Acct-Delay-Time = 0 NAS-IP-Address = 192.168.2.200 # Executing section preacct from file /etc/freeradius/sites-enabled/default +- entering group preacct {...} ++[preprocess] returns ok ... ... ++[sql.authorize] returns ok ++? if (Check-Quota == "1") (Attribute Check-Quota was not found) ? Evaluating (Check-Quota == "1") -> FALSE ++? if (Check-Quota == "1") -> FALSE Sending Accounting-Response of id 129 to 192.168.2.200 port 55834 Framed-Compression := Van-Jacobson-TCP-IP Framed-MTU := 1492 Acct-Interim-Interval := 60 Framed-Protocol := PPP Mikrotik-Rate-Limit := "64k/64k" Check-Quota := 1 Finished request 1. i tried putting 'sql.authorize' into accouting { }, but same 'problem' . My radgroupreply: GroupName Attribute Value op prio ondaX Check-Quota 1 := 0 any suggestion ? On 04/12/2012 19:36, Arran Cudbard-Bell wrote:
On 4 Dec 2012, at 20:50, "Alexandre J. Correa (Onda)" <alexandre@onda.net.br> wrote:
Hello,
I need to track some type of 'user group'. i´m doing this to not overload my database servers.
into the radgroupreply table i need to 'create' one attribute like:
Check-Bandwidth := [0,1]
i added this attribute in groupreply, in my dictionary file and i can see this attribute in the 'authorization' section.
How i can pass it to 'accouting' section ? maybe setting global variable for this session ?
Call sql.authorize in preacct.
-Arran - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Sds. Alexandre Jeronimo Correa Sócio-Administrador Office: +55 34 3351 3077 Onda Internet www.onda.net.br
On 12/05/2012 12:53 PM, Alexandre J. Correa (Onda) wrote:
Finished request 0. Going to the next request Waking up in 4.9 seconds. rad_recv: Accounting-Request packet from host 192.168.2.200 port 55834, id=129, length=149 Service-Type = Framed-User Framed-Protocol = PPP
As you can see - Accounting packets don't automatically contain attributes you send in an Accept. The only attribute that is "reflected" from Accept to accounting packets is "Class". You have two options; 1. As per Alan's suggestion, use a database to store the quota (in post-auth) then re-read it in accounting/preacct. 2. (ab)use the "Class" attribute for it, if your NAS is RFC-compliant and properly reflects the attribute. Be warned: I've seen some NASes that do this usually, but fail in e.g. 1% of cases.
Alexandre J. Correa (Onda) wrote:
I need to track some type of 'user group'. i´m doing this to not overload my database servers.
Then you need to upgrade your database.
into the radgroupreply table i need to 'create' one attribute like:
Check-Bandwidth := [0,1]
i added this attribute in groupreply, in my dictionary file and i can see this attribute in the 'authorization' section.
How i can pass it to 'accouting' section ? maybe setting global variable for this session ?
Use a database. That's what databases are for. Maybe the redis module would help. It's lower overhead than other databases. Alan DeKok.
participants (4)
-
Alan DeKok -
Alexandre J. Correa (Onda) -
Arran Cudbard-Bell -
Phil Mayers