pool name per nas AND per user
Hello, I have freeradius authenticating ADSL users (several types ADSL). request are comming from several BAS (my NASes). I would like freeradius to give customers IP addresses from differents IP pools based on the NAS from which the request come from (huntgroups does it perfectly today) but also based on the type for ADSL is authenticated (this information is stored in the sql database and so the NAS is completely unaware of it) ex: As a reminder, i want thoose pools pool_NAS1_ADSL512 pool_NAS1_ADSL1024 pool_NAS2_ADSL512 pool_NAS2_ADSL1024 if i am user1 who owns a 1024kb/s ADSL account, I want to have Pool-Name pool_NAS1_ADSL1024 if the request comes from NAS1 and pool_NAS2_ADSL1024 if the request comes from NAS2...and so on. Any idea?
Use unlang to set Pool-Name. Ivan Kalik Kalik Informatika ISP Dana 14/10/2008, "Alexandre Chapellon" <alexandre.chapellon@mana.pf> piše:
Hello,
I have freeradius authenticating ADSL users (several types ADSL). request are comming from several BAS (my NASes). I would like freeradius to give customers IP addresses from differents IP pools based on the NAS from which the request come from (huntgroups does it perfectly today) but also based on the type for ADSL is authenticated (this information is stored in the sql database and so the NAS is completely unaware of it)
ex:
As a reminder, i want thoose pools
pool_NAS1_ADSL512
pool_NAS1_ADSL1024
pool_NAS2_ADSL512
pool_NAS2_ADSL1024
if i am user1 who owns a 1024kb/s ADSL account, I want to have Pool-Name pool_NAS1_ADSL1024 if the request comes from NAS1 and pool_NAS2_ADSL1024 if the request comes from NAS2...and so on.
Any idea? - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
tnt@kalik.net a écrit :
Use unlang to set Pool-Name.
OK, i guess this soltuion is flexible enough for want i want to do. So In the authorize section i tried to add an update directive where i define a variable which has the result of the sql query as value. Then i want to concatenate this variable with the value of the Pool-Name attribute as defined in the users file and set it as the new value of Pool-Name. I think this would work for what i want to do. update control { "%{MANA-DSL-Type}" = mysqldb:"SELECT value FROM radcheck WHERE attribute='Subscription-Type' AND username='%{User-Name}'" if ("%{MANA-DSL-Type}") { Pool-Name := "%{Pool-Name}""%{ADSL-Type}" } } My problem is i don't know how to define variable with unlang. I have tried making a new directionary with special attribute but it doesn't seems to work. here is what ot looks like: # -*- text -*- # Define internal attribute to use for ME # VENDOR ME 11434 BEGIN-VENDOR ME ATTRIBUTE MANA-DSL-Type 1 string END-VENDOR ME Does anyone knows how i can acheive this?
Ivan Kalik Kalik Informatika ISP
Dana 14/10/2008, "Alexandre Chapellon" <alexandre.chapellon@mana.pf> piše:
Hello,
I have freeradius authenticating ADSL users (several types ADSL). request are comming from several BAS (my NASes). I would like freeradius to give customers IP addresses from differents IP pools based on the NAS from which the request come from (huntgroups does it perfectly today) but also based on the type for ADSL is authenticated (this information is stored in the sql database and so the NAS is completely unaware of it)
ex:
As a reminder, i want thoose pools
pool_NAS1_ADSL512
pool_NAS1_ADSL1024
pool_NAS2_ADSL512
pool_NAS2_ADSL1024
if i am user1 who owns a 1024kb/s ADSL account, I want to have Pool-Name pool_NAS1_ADSL1024 if the request comes from NAS1 and pool_NAS2_ADSL1024 if the request comes from NAS2...and so on.
Any idea? - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
So In the authorize section i tried to add an update directive where i define a variable which has the result of the sql query as value. Then i want to concatenate this variable with the value of the Pool-Name attribute as defined in the users file and set it as the new value of Pool-Name. I think this would work for what i want to do.
update control { "%{MANA-DSL-Type}" = mysqldb:"SELECT value FROM radcheck WHERE attribute='Subscription-Type' AND username='%{User-Name}'" if ("%{MANA-DSL-Type}") { Pool-Name := "%{Pool-Name}""%{ADSL-Type}" } }
Ugh. 1. Forget custom dictionaries. Use already defined temporary attributes from freeradius internal dictionary (ie. Tmp-String-0,..., Tmp-Integer-0, ... etc.) 2. "%{}" goes around the value not attribute name: Tmp-String-0 = "%{mysqldb:SELECT value FROM...}" 3. You can't put if inside the control section. You can put update control inside if section. update control { read temporary value from the database } if(whatever) { update control { ... Ivan Kalik Kalik Informatika ISP
tnt@kalik.net a écrit :
So In the authorize section i tried to add an update directive where i define a variable which has the result of the sql query as value. Then i want to concatenate this variable with the value of the Pool-Name attribute as defined in the users file and set it as the new value of Pool-Name. I think this would work for what i want to do.
update control { "%{MANA-DSL-Type}" = mysqldb:"SELECT value FROM radcheck WHERE attribute='Subscription-Type' AND username='%{User-Name}'" if ("%{MANA-DSL-Type}") { Pool-Name := "%{Pool-Name}""%{ADSL-Type}" } }
Ugh.
I knew you was going to said that :)
1. Forget custom dictionaries. Use already defined temporary attributes from freeradius internal dictionary (ie. Tmp-String-0,..., Tmp-Integer-0, ... etc.)
good
2. "%{}" goes around the value not attribute name:
Tmp-String-0 = "%{mysqldb:SELECT value FROM...}"
understood
3. You can't put if inside the control section. You can put update control inside if section.
update control { read temporary value from the database }
if(whatever) { update control { ...
ok here is what i have now: # I want the pool to be the concatenation of pool-name as previously set by huntgroup in # users file, the expanded value of tmp-String-0 and the string "_pool" if possible update control { Tmp-String-0 = "%{mysqldb:SELECT forfait FROM test WHERE username='%{User-Name}'}" Pool-Name := "%{Pool-Name}""%{Tmp-String-0}"_pool } Two problems I can see in the debug output: - 1 - control returns noop (the update control is placed at the end ofthe authorize section after pap), and so nothing happens... - 2 - when expanded "%{Pool-Name}" is empty whereas users as been proceed before the "update control". Any idea? here is the revelant debug: rlm_sql (mysqldb): - sql_xlat expand: %{User-Name} -> scott rlm_sql (mysqldb): sql_set_user escaped user --> 'scott' expand: SELECT forfait FROM test WHERE username='%{User-Name}' -> SELECT forfait FROM test WHERE username='scott' expand: /var/log/freeradius/sqltrace.sql -> /var/log/freeradius/sqltrace.sql rlm_sql (mysqldb): Reserving sql socket id: 4 rlm_sql_mysql: query: SELECT forfait FROM test WHERE username='scott' rlm_sql (mysqldb): - sql_xlat finished rlm_sql (mysqldb): Released sql socket id: 4 expand: %{mysqldb:SELECT forfait FROM test WHERE username='%{User-Name}'} -> ADSL512 expand: %{Pool-Name} -> ++[control] returns noop
Ivan Kalik Kalik Informatika ISP
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Two problems I can see in the debug output:
- 1 - control returns noop (the update control is placed at the end ofthe authorize section after pap), and so nothing happens...
That's OK. AFAIK it returns noop (and not updated) even when attributes are changed.
- 2 - when expanded "%{Pool-Name}" is empty whereas users as been proceed before the "update control".
Use lists. "%{control:Pool-Name}" Ivan Kalik Kalik Informatika ISP
tnt@kalik.net a écrit :
Two problems I can see in the debug output:
- 1 - control returns noop (the update control is placed at the end ofthe authorize section after pap), and so nothing happens...
That's OK. AFAIK it returns noop (and not updated) even when attributes are changed.
ok
- 2 - when expanded "%{Pool-Name}" is empty whereas users as been proceed before the "update control".
Use lists. "%{control:Pool-Name}"
Great works like a champ.... just needed a little training with unlang and variable manipulation.! Unlang rules!
Ivan Kalik Kalik Informatika ISP
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
From reading online, I understand its possible to run external script but I haven't been able to find a simple example.
I would like to know if this is possible. If so, could somebody help with a simple example? I want this script to be run on post-auth REJECT which i believe goes on the following sub-section of post-auth. Post-Auth-Type REJECT { attr_filter.access_reject } The script is very simple. script name: test.sh #!/bin/sh echo "user bla bla rejected" >> /tmp/test.txt I am running freeradius-server-2.1.1. As you can see, the script is pretty simple. I appreciate all the help. Thanks AM
Madwifi wrote:
From reading online, I understand its possible to run external script but I haven't been able to find a simple example.
How about using the "exec" module that is shipped with the server?
I would like to know if this is possible. If so, could somebody help with a simple example?
The server ships with many examples. It's useful to look there FIRST before reading random pages online. Alan DeKok.
tnt@kalik.net a écrit :
Use unlang to set Pool-Name.
OK, i guess this soltuion is flexible enough for want i want to do. So In the authorize section i tried to add an update directive where i define a variable which has the result of the sql query as value. Then i want to concatenate this variable with the value of the Pool-Name attribute as defined in the users file and set it as the new value of Pool-Name. I think this would work for what i want to do. update control { "%{MANA-DSL-Type}" = mysqldb:"SELECT value FROM radcheck WHERE attribute='Subscription-Type' AND username='%{User-Name}'" if ("%{MANA-DSL-Type}") { Pool-Name := "%{Pool-Name}""%{ADSL-Type}" } } My problem is i don't know how to define variable with unlang. I have tried making a new directionary with special attribute but it doesn't seems to work. here is what ot looks like: # -*- text -*- # Define internal attribute to use for ME # VENDOR ME 11434 BEGIN-VENDOR ME ATTRIBUTE MANA-DSL-Type 1 string END-VENDOR ME Does anyone knows how i can acheive this? Oops here is the error i get: ERROR: Unknown vendor name in attribute name "%{MANA-DSL-Type}"
Ivan Kalik Kalik Informatika ISP
Dana 14/10/2008, "Alexandre Chapellon" <alexandre.chapellon@mana.pf> piše:
Hello,
I have freeradius authenticating ADSL users (several types ADSL). request are comming from several BAS (my NASes). I would like freeradius to give customers IP addresses from differents IP pools based on the NAS from which the request come from (huntgroups does it perfectly today) but also based on the type for ADSL is authenticated (this information is stored in the sql database and so the NAS is completely unaware of it)
ex:
As a reminder, i want thoose pools
pool_NAS1_ADSL512
pool_NAS1_ADSL1024
pool_NAS2_ADSL512
pool_NAS2_ADSL1024
if i am user1 who owns a 1024kb/s ADSL account, I want to have Pool-Name pool_NAS1_ADSL1024 if the request comes from NAS1 and pool_NAS2_ADSL1024 if the request comes from NAS2...and so on.
Any idea? - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (4)
-
Alan DeKok -
Alexandre Chapellon -
Madwifi -
tnt@kalik.net