Difference between revisions of "Limiting a user to a given amount of traffic II"

From MikroTik Wiki
Jump to: navigation, search
(Script to limit bandwith-hungry users to a certain amount of data per day)
 
Line 25: Line 25:
 
It shoud be added a scheduler that will run this script every 5 minutes or so.
 
It shoud be added a scheduler that will run this script every 5 minutes or so.
 
Another scheduler to reset counters daily " /que simple reset-counters".
 
Another scheduler to reset counters daily " /que simple reset-counters".
 +
 +
==Limitations==
 +
If the MT box is reset the traffic counters will be reset and the speed will return to normal (e.g. power outage)

Revision as of 09:13, 14 December 2005

I have users that never spend 100 mb daily but need the good speed, And i have users that would download the whole internet in a day if they could. This way 'easy' users will have good speed for browsing , chatting with camera, and some small downloads. And the 'bandwidth hungry' users will suffer slower speeds after they cross their 100MB during the day. But, thats not that bad , users can download during the night hours 1am-10am when i disable this script and give greater speads, cose the network is slightly used.

For the others information here is the complete script that is tested and works.

:local traf;
/queue simple
  :for i from=1 to= 254 do =  {
    :if ([/queue simple find target-addresses=("192.168.1." . $i)] != "") do={
      :set traf [get [find target-addresses=("192.168.1." . $i)] total-bytes]
      :if ($traf  > 104857600) do = {
        set [find target-addresses=("192.168.1." . $i)] max-limit= 32000/64000
      }
    }
  }

This script will check all the simple queues shearching their target adresses and will search a whole 192.168.1.0/24 subnet. It will read their total-bytes (recieved + transmited) and will check them if they crosed a limit of 100 MB ( 104857600 bytes) If they did , they will be limited to lower speed (64k/64k)

You can change the subnet, the limit, and the lower speed acording to your needs.

It shoud be added a scheduler that will run this script every 5 minutes or so. Another scheduler to reset counters daily " /que simple reset-counters".

Limitations

If the MT box is reset the traffic counters will be reset and the speed will return to normal (e.g. power outage)