Menu

Mikrotik disconnect hack

MattWarren
2009-04-02
2017-12-07
  • MattWarren

    MattWarren - 2009-04-02

    If anyone needs it I have added a little code (not the cleanest but works) to disconnect the Mikrotik session when disabling an account.

    File include/userOperations.php

    Appx line 75 add below $res = $dbSocket->query($sql);
    I added:
    $getip = mysql_query("SELECT * FROM radacct WHERE UserName = '".$user."' ORDER BY RadAcctId DESC LIMIT 1");
    $ipinfo = mysql_fetch_array($getip);
    $nasip = $ipinfo['NASIPAddress'];
    $userip = $ipinfo['FramedIPAddress'];
    system('echo "Framed-IP-Address := '.$nasip.'" | radclient -x '.$userip.':1700 disconnect yoursharekey', $whocares);

    just replace the 1700 with the port number your Mikrotik is listeningfor and replace yoursharekey with your shared key.

    Also make sure that the incoming is enabled in the radius screen of the Mikrotik unit, this is also where you set the port.

    This does not run when deleting the account, but would need to be added in that area as well.

    Hope it helps.

    Matt

     
    • Liran Tal

      Liran Tal - 2009-04-06

      Hey Matt,

      You are adding this piece of code in the userDisable function which means it will run only when the user is rendered disabled.

      Wouldn't it make more sense to add this functionality which supports Mikrotik in the disconnect function?

       
    • Admir Tane

      Admir Tane - 2009-05-08

      Hi matt
      I wanna use your code slightly in a different way.
      My NAS does only mac wireless authentication so to disconnect one client I use

      echo "User-Name='xx:xx:xx:xx:xx:xx'" | radclient -c '1' -n '3' -r '3' -t '3' -x 'NASIp:NASPort' 'disconnect' 'secret' 2>&1

      How can i implement this in userOperations.php

       
      • Liran Tal

        Liran Tal - 2009-05-09

        I am aware of this demand, how can we integrate this into dalo's core?

         
  • Bart

    Bart - 2013-04-16

    Hello, i use 9.9
    when i disconnect a user from my mikrotik, i need to add an attribut: ,Framed-IP-Address=192.168.88.248"
    then it works.. is there a plugin/fix for it?

     
  • Mirek Rozewicz

    Mirek Rozewicz - 2013-04-16

    I had almost finished module to dalo with you can easly disconnect users form Mikrotik without that strange "hacks" when i finish and test it will post code here or send it to Liran.

    In palns i have write module with "live" showing users trafic readed form MT and couple more ideas.

    I work only with devices based on RouterOS so I will introduce a lot of facilities to work with these devices.

    Best regards
    fuggii

     
  • Liran Tal

    Liran Tal - 2013-05-29

    Hey Fuggi,

    Please feel free to share it here or on the mailing list too.

     
  • Cobslee

    Cobslee - 2014-10-31

    Hello all! I am from Ghana and I really like this application.
    Has anyone been able to integrate the mikrotik hotspot user disconnect feature in daloradius?

     
  • Oscar

    Oscar - 2014-11-13

    Hi all...
    I have the same problem on mikrotik.
    Configured DolaRadius 0.9-9.
    Configured more than 50 mikrotiks runing with this Radius.
    Sometimes i have active users on Mikrotik and on Radius they ara with connection finished (AcctStopTime<>null). Average 10%
    And some times I have users inactive on mikrotik and actives on radius (AcctStopTime is null). Average 1%
    Talk to mikrotik and send supout files and they doesn't fins anything.
    Is there someone who can help me on make it work better ?

    I'm from spain.

    Thank's a lot !!
    Oscar.

     
    • Liran Tal

      Liran Tal - 2014-11-13

      Hi Oscar,

      Great to hear you're working with daloRADIUS.
      If you're referring to the problem of having stale sessions in the radius
      db for the accounting table then its a somewhat known issue (maybe there's
      a better solution for that today), but there's a script provided in the
      daloRADIUS contrib/ directory to update these stale sessions.

      On Thu, Nov 13, 2014 at 1:08 PM, Oscar oskarjj@users.sf.net wrote:

      Hi all...
      I have the same problem on mikrotik.
      Configured DolaRadius 0.9-9.
      Configured more than 50 mikrotiks runing with this Radius.
      Sometimes i have active users on Mikrotik and on Radius they ara with
      connection finished (AcctStopTime<>null). Average 10%
      And some times I have users inactive on mikrotik and actives on radius
      (AcctStopTime is null). Average 1%
      Talk to mikrotik and send supout files and they doesn't fins anything.
      Is there someone who can help me on make it work better ?

      I'm from spain.

      Thank's a lot !!
      Oscar.


      Mikrotik disconnect hack
      https://sourceforge.net/p/daloradius/discussion/684101/thread/5a3cb8d0/?limit=25#e497


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/daloradius/discussion/684101/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --

      Sincerely, Liran Tal

      Founder and CTO
      Linux and Open Source
      Enginx - http://enginx.com

       
      • Oscar

        Oscar - 2014-11-13

        Hi Liran,

        sorry but i can't find the daloRADIUS contrib/ directory.
        And what do you mean:
        maybe there's a better solution for that today

        I'm really happy with daloRadius but i have to learn a lot. At the momento it is working perfecly with more tan 50.000 users. I have to learn how to get máximum of daloRadius-mikrotik connection.

        Thank's a lot !

         
  • asif

    asif - 2017-12-07

    Can anyone guide me how to connect Multiple MicroTik with Radius

     

Log in to post a comment.