Migrating from Mikrotik NAS to FreeBSD

Cassiano Peixoto peixotocassiano at gmail.com
Wed Jul 22 14:55:58 CEST 2015


Hi Stefan,


On Tue, Jul 21, 2015 at 8:28 PM, Stefan Paetow <Stefan.Paetow at jisc.ac.uk>
wrote:

> >>Can you send both sets of attributes in each response?
> >
> >Yes, i think so. I suppose, mpd will just ignore what is not valid.
>
> That would be the easiest bet, yes. Is that also the case for the Mikrotik
> NAS?
>
>

Yes it is. What's your another idea here?



> >Yes, i think it would be possible to add a nas type, like mikrotik, mpd,
> >etc.
>
> There are only limited types of nastype you can set. You could use the
> short name instead.
>
> >Do you have an example how it could be done using unlang?
>
> But either way, you can use this kind of unlang:
>
> if ("%{client:shortname}" == 'mikrotik-15') {
> {
>         update reply {
>                 # strip the non-Mikrotik attributes
>         }
> }
>
>
>
I have the following value in Mikrotik-Rate-Limit:

2048k/2048k 384k/384k 768k/768k 100/100 8 0K/0K

And this is the two values to mpd-limit reply:

in#1=all rate-limit 2048000 384000 768000 pass
out#1=all rate-limit 2048000 384000 768000 pass

Following your suggestion, i've been thinking to use something like this in
authorize section:

authorize {
        preprocess
        auth_log
        chap
        mschap
        suffix
        eap {
                ok = return
        }
        unix
        files
        sql
        expiration
        logintime
        pap

                if ("%{client:shortname}" == 'mpd-nas') {
                        {
                        update reply {
                                        Tmp-String-0 = %{sql:SELECT Value
FROM radreply  WHERE Username = %{User-Name} and attribute
='Mikrotik-Rate-Limit'}
                                        Tmp-String-1 = %{sql:SELECT Value
FROM radreply  WHERE Username = %{User-Name} and attribute
='Mikrotik-Rate-Limit'}
                                        # here i still have to convert to
mpd values, but i don't know how.
                                        mpd-limit = Tmp-String-0
                                        mpd-limit = Tmp-String-1
                        }
                }
}


What do you think? Am i right? how could i convert Tmp-String-0 and 1 to
mpd-limit output in/out? should i use awk?

Thanks for your help.


More information about the Freeradius-Users mailing list