Mikrotik Rate Limit attribute from query.

Nick Porter nick at portercomputing.co.uk
Thu Oct 13 07:21:39 UTC 2022


The simplest method for that would be an SQL xlat.  Presuming your SQL 
module name is sql, something like:

update reply {
     &Mikrotik-Rate-Limit := "%{sql:SELECT CASE WHEN sync = 1 THEN 
REPLACE(CAST(idvelocidad as char) + 'K', ' ', '') ELSE 
REPLACE(CAST(idvelocidad /2 as char + 'K/' + CAST(idvelocidad as 
char)+'K', ' ', '') END FROM SubAccounts WHERE Login = '%{SQL-User-Name}'}"
}

On 13/10/2022 03:42, Carlos Botejara wrote:
> Hi All.
> I'm migrating ClearBox Radius Software to freeradius, And I need to pass
> the attribute Mikrotik-Rate-Limit via query.
>
> The Query for ClearBox is:
> "SELECT 'Mikrotik-Rate-Limit' AS Expr1, \
>    CASE WHEN sync = 1 THEN \
>     REPLACE(CAST(idvelocidad as char) + 'K',' ','') \
>     ELSE \
>     REPLACE(CAST(idvelocidad /2 as char)+'K/'+ CAST(idvelocidad  as
> char)+'K',' ','') \
>     END \
>     AS Expr2 \
>    FROM SubAccounts with(nolock) \
>    WHERE Login = '%{SQL-User-Name}'"
>
> This query takes the bandwidth of a table in the CRM software. If the
> client is a business (synchronization), the bandwidth is symmetric, but if
> the client is an ordinary client, the bandwidth is not symmetric and the
> upload bandwidth is divided by 2 and the upload bandwidth is divided by 2.
> download is integer.
>
> How can I keep this in freeradius and pass the parameter through a query?
>
> Thanks
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

-- 
Nick Porter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 665 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20221013/2759a0b6/attachment.sig>


More information about the Freeradius-Users mailing list