RES: Old "problem" with backquote and Mikrotik-Rate-Limit (fixed)

Rafael Labiak Olivastro rolivastro at
Fri Sep 28 15:33:10 CEST 2018

Perfect, fits like a glove. =)

I spent almost 3 days to figure out that way and now with just minutes you explain a much beter way, just the freeradius´s creator could be done this.

Thanks again, when you need something from Brazil let me know, maybe I can help you. 😉

De: Alan DeKok<mailto:aland at>
Enviado:sexta-feira, 28 de setembro de 2018 09:06
Para: FreeRadius users mailing list<mailto:freeradius-users at>
Assunto: Re: Old "problem" with backquote and Mikrotik-Rate-Limit (fixed)

On Sep 28, 2018, at 8:34 AM, Rafael Labiak Olivastro <rolivastro at> wrote:
> I was facing a problem with backquotes and the Mikrotik-Rate-Limit atribute, this problem happened when I put  something like “%{sql: select....}” in the attribute´s value, everything worked fine BUT in the final result the backquotes is not removed, causing problems in the NAS.

  If the value in SQL has back quotes, they can be removed.  I'm not sure where the extra back quotes would come from.

> 1 – Create a new file called “/usr/bin/echo2” with following contents and make it executable (chmod 755 /usr/sbin/echo2):
> #!/bin/bash
> echo $1 | sed -r "s/\`//g"
> 2 – Edit file /etc/raddb/sites-available/default and ADD the following in the post-auth section:
>        if (reply:Mikrotik-Rate-Limit =~ /.*\`$/i) {
>            update reply {
>                &Mikrotik-Rate-Limit := `/usr/bin/echo2 %{0}`
>            }

  There's a better solution.  Just do this:

     if (reply:Mikrotik-Rate-Limit =~ /\`(.*)\`$/i) {
           update reply {
               &Mikrotik-Rate-Limit := "%{1}"

  You can do a regex match on just a substring, and then give that substring to an attribute.

  It also avoids forking an external program, which is *slow*, and therefore fragile.

> Again, thanks a lot for the work with FreeRadius, you and your team deserve all my respects.

  You're welcome.  We try hard.

  Alan DeKok.

List info/subscribe/unsubscribe? See

More information about the Freeradius-Users mailing list