Menu

Profiles parameters for per-device limits for Mikrotik

Help
Atomic
2015-01-22
2015-02-09
  • Atomic

    Atomic - 2015-01-22

    Hello.

    I need such behaviour of system:
    1) User input some URL
    2) Is user is not connected - he will be redirected on login page
    3) After pressing Click to connect (or any other type of access allowing buttons) - user should be redirected to requested page
    4) When time limit (or any other limit) is reached - user should be redirected again to login page and then immediately can press login button again.

    My system works like this: after login and time limit reached user redirected to alogin.html page. And not redirected to any other place. alogin.html page shows logged_in=yes.
    If I try to enter some URL - it will be opened and new session automatically started without pressing button. Rd-Reset-Interval-Time is ignored?

    Profile config:
    Check Rd-Total-Time:=30
    Check Rd-Reset-Type-Time:=dynamic
    Check Rd-Cap-Type-Time:=hard
    Check Rd-Reset-Interval-Time:=60
    Check Rd-Mac-Counter-Data:=1
    Reply Fall-Through:=1

     
  • Atomic

    Atomic - 2015-01-22

    Ok, figured out couple of things.
    1) If I want to limit time - I should use Rd-Mac-Counter-Time.
    2) There is a couple of errors in policy.conf

    Error : rlm_sql (sql),database query error, SELECT IFNULL(SUM(acctsessiontime - GREATEST((1421934091 - UNIX_TIMESTAMP(acctstarttime)), 0)) FROM radacct WHERE username='click_to_connect@xxx' AND callingstationid='xx-xx-xx-xx-xx-xx' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '1421934091',You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM radacct WHERE username='click_to_connect@xxx' AND callingstationid' at line 1
    

    To fix it you can use patch:

    --- policy.conf.orig    2015-01-12 06:53:16.000000000 +0200
    +++ policy.conf 2015-01-22 15:51:58.991066903 +0200
    @@ -136,21 +136,21 @@
                     # we can now use it in a query
                     if("%{control:Rd-Tmp-Avail-Time}"){ #This indicates it it a device!
                         update control {
    -                        Rd-Used-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime - GREATEST((%{control:Rd-Start-Time} - UNIX_TIMESTAMP(acctstarttime)), 0)) FROM radacct WHERE callingstationid='%{request:User-Name}' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%{control:Rd-Start-Time}'}"
    +                        Rd-Used-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime - GREATEST((%{control:Rd-Start-Time} - UNIX_TIMESTAMP(acctstarttime)), 0)),0) FROM radacct WHERE callingstationid='%{request:User-Name}' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%{control:Rd-Start-Time}'}"
                         }
                     }
                     else{
                         #Here we need to see if the counter is to be applied on the device level and there is a device present in the request
                         if((control:Rd-Mac-Counter-Time)&&(request:Calling-Station-Id)){
                             update control {
    -                            Rd-Used-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime - GREATEST((%{control:Rd-Start-Time} - UNIX_TIMESTAMP(acctstarttime)), 0))\
    +                            Rd-Used-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime - GREATEST((%{control:Rd-Start-Time} - UNIX_TIMESTAMP(acctstarttime)), 0)),0)\
                                 FROM radacct WHERE username='%{request:User-Name}' AND callingstationid='%{request:Calling-Station-Id}' \
                                 AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%{control:Rd-Start-Time}'}"
                             }
                         }
                         else{
                             update control {
    -                            Rd-Used-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime - GREATEST((%{control:Rd-Start-Time} - UNIX_TIMESTAMP(acctstarttime)), 0))\
    +                            Rd-Used-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime - GREATEST((%{control:Rd-Start-Time} - UNIX_TIMESTAMP(acctstarttime)), 0)),0)\
                                 FROM radacct WHERE username='%{request:User-Name}' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%{control:Rd-Start-Time}'}"
                             }
                         }
    

    But still have question. Why session after reset starting again and not redirecting to login page?

     

    Last edit: Atomic 2015-01-22
  • Atomic

    Atomic - 2015-01-22

    My system works like this: after login and time limit reached user redirected to alogin.html page. And not redirected to any other place. alogin.html page shows logged_in=yes.
    Why session after reset starting again and not redirecting to login page?

    To fix this - COOKIE authorization should be disabled in Mikrotik Hotspot server profile (on Login tab)

     

    Last edit: Atomic 2015-01-22
  • Atomic

    Atomic - 2015-02-09

    By the way.
    Can I set
    Rd-Reset-Interval-Time
    to 1?
    I need to allow user start new session immediately after closing old session
    Or better set
    Rd-Reset-Interval-Time=Rd-Total-Time+1sec?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.