I described the new module but the goal was to describe an additional instance sql1 that would use the same rlm_sql module. I describe sql and sql1 modules in file /etc/freeradius/mods-enabled/sql and I'm getting an error for the non-existent file 'rlm_sql1'. # Loading module "sql" from file /etc/freeradius/mods-enabled/sql sql { driver = "rlm_sql_postgresql" server = "" port = 0 login = "" password = <<< secret >>> radius_db = "dbname=radius host=postgresql2 port=5432 user=radius password=radpass" ...... } sql1 { driver = "rlm_sql_postgresql" server = "" port = 0 login = "" password = <<< secret >>> radius_db = "dbname=radius host=postgresql3 port=5432 user=radius password=radpass"...... } rlm_sql (sql): Driver rlm_sql_postgresql (module rlm_sql_postgresql) loaded and linked Creating attribute SQL-Group /etc/freeradius/mods-enabled/sql[108]: Failed to link to module 'rlm_sql1': /usr/lib/freeradius/rlm_sql1.so: cannot open shared object file: No such file or directory I repeating read on manual https://wiki.freeradius.org/modules/Rlm_sql which sayed: You can create multiple named instances like so: sql sql_instance1 { ... } sql sql_instance2 { ... } I add word sql before both instances sql and sql1 # Loading module "sql" from file /etc/freeradius/mods-enabled/sql sql sql { driver = "rlm_sql_postgresql" server = "" port = 0 login = "" password = <<< secret >>> radius_db = "dbname=radius host=postgresql2 port=5432 user=radius password=radpass" ...... } sql sql1 { driver = "rlm_sql_postgresql" server = "" port = 0 login = "" password = <<< secret >>> radius_db = "dbname=radius host=postgresql3 port=5432 user=radius password=radpass"...... } Now this part works successfully. In file /etc/freeradius/sites-enabled/default I wrote group for both instances group { sql { fail = 1 notfound = return noop = 2 ok = return updated = 3 reject = return userlock = 4 invalid = 5 handled = 6 } sql1 { fail = 1 notfound = return noop = 2 ok = return updated = 3 reject = return userlock = 4 invalid = 5 handled = 6 } } Next my goal if statements. In file /etc/freeradius/sites-enabled/default I wrote if statements with update request if(ADSL-Agent-Circuit-Id){ if(ADSL-Agent-Circuit-Id =~ /.+\..+\..+\..+/){ update request { Tmp-String-2 := ADSL-Agent-Circuit-Id sql1 } }else{ update request { Tmp-String-2 := "127.0.0.1" } } # Loading authorize {...} /etc/freeradius/sites-enabled/default[122]: Missing attribute value /etc/freeradius/sites-enabled/default[120]: Failed to parse "update" subsection. /etc/freeradius/sites-enabled/default[119]: Failed to parse "if" subsection. /etc/freeradius/sites-enabled/default[71]: Errors parsing authorize section. I repeat read whitch Alan wrote: Just refer to them by name. if (a) { sql1 } else { sql2 } I replace sql1 place from update request {...} to if statement if(ADSL-Agent-Circuit-Id){ if(ADSL-Agent-Circuit-Id =~ /.+\..+\..+\..+/){ sql1 update request { Tmp-String-2 := ADSL-Agent-Circuit-Id } }else{ update request { Tmp-String-2 := "127.0.0.1" } } I tried sent packet to radius server ...... (0) if (ADSL-Agent-Circuit-Id){ (0) if (ADSL-Agent-Circuit-Id) -> TRUE (0) if (ADSL-Agent-Circuit-Id) { (0) if (ADSL-Agent-Circuit-Id =~ /.+\..+\..+\..+/){ (0) if (ADSL-Agent-Circuit-Id =~ /.+\..+\..+\..+/) -> TRUE (0) if (ADSL-Agent-Circuit-Id =~ /.+\..+\..+\..+/) { (0) sql1: EXPAND %{User-Name} (0) sql1: --> aa:bb:cc:dd:ee:ff (0) sql1: SQL-User-Name set to 'aa:bb:cc:dd:ee:ff' ...... Voila, I have two working instances. I hope I didn’t miss anything. Pagarbiai, Giedrius 2021-10-11, pr, 21:17 Alan DeKok <aland@deployingradius.com> rašė:
On Oct 11, 2021, at 2:04 PM, Giedrius Baronas <g.baronas@gmail.com> wrote:
I will try to describe it more precisely. If radius receives a packet with radius attribute "ADSL-Agent-Circuit-Id" then I need to use a sql1 instance. In the else statement I need it to use sql2 instance. How can I set sql instances ?
Just refer to them by name.
if (a) { sql1 } else { sql2 }
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Pagarbiai, Giedrius 861569551