I need script -fair usage policy-

I have mikrotik 6.28 server with simple configuration :

/ip address
add address=192.168.100.1/24 interface=Mangers network=192.168.100.0
add address=192.168.1.50/24 interface=External network=192.168.1.0
/ip dns
set allow-remote-requests=yes servers=208.67.222.222,208.67.220.220
/ip firewall nat
add action=masquerade chain=srcnat out-interface=!Mangers
add action=redirect chain=dstnat dst-port=80 in-interface=External protocol=
tcp to-ports=8080
add action=redirect chain=dstnat dst-port=80 protocol=tcp to-ports=8080
/ip proxy
set cache-on-disk=yes cache-path=disk2 enabled=yes
/ip route
add distance=1 gateway=192.168.1.1

I need a script to limit a each ip address to 300MB of traffic daily and when it exceed
300MB put it in address lists and decrease its bandwidth to 256k to the end of the day.
Next day it reset counters and start again.

Please help
Eng. Amgad

I am not sure how you limit bandwidth.
But I do know how to possibly get the traffic.

{
    :local traffic 0
    :set traffic ($traffic + [/interface get [/interface find name=Wan] rx-byte])
    :set traffic ($traffic + [/interface get [/interface find name=Wan] tx-byte])
    :set traffic (traffic / 1000000)
    :put ("traffic: " . $traffic . "MB")
    :if ($traffic > 300) do={
        :put "traffic limit exceeded!"
    }
}

You can set a scheduler to check for this every few minutes, and then another scheduler to reset the counters every 24 hours.
That is if it is even possible to reset the counters, in which case you may need save the number each day?

You can try and read up on some if it here:

First Of all thanks for your response
But I think the script should check local int for local IP’s not wan
I try it but it do not work

I hope you can help

I just wrote “Wan” because that was the name of my external interface.

But you want it per IP address on a LAN? I am not sure you can limit the bandwidth for a specific IP address on a shared LAN. As far as I know, any bandwidth limiting you wanna enforce is either per interface or something to do with queues.
Maybe someone can prove me wrong?

I don’t know much on that subject, and I haven’t worked with queues before.

In Fact I am doing it now manually by making a simple queue for any IP with any speed I want
I want and it works well.

But I have to check the all IP traffic manually all the time and this is a very bad work.

I found this article:

http://forum.mikrotik.com/t/how-to-limit-a-user-to-a-given-amount-of-traffic/237/1

this same as I need but It did not work with me.

Is this the right place for my question ??