Limit download/upload speed per IP

Hello guys,

I’ve searched on this forum and on google, i’ve found 100’s of exemples how to do this but it seems to be that they are plenty ways to fix it, with lots of options that i don’t have it clear. I hope that one of you can explain me the most simple way to limit the download and upload speed per IP address.

Short story:

  • IP range is 10.0.0.0/24
  • IP of routerboard id 10.0.0.1
  • max downloadspeed per IP is 10Mbit
  • max uploadspeed per IP is 10Mbit
  • Port 1, 2, 3 are in a bridge called “bridge1 - Bureau” (LAN)
  • WAN is port 6 called “ether6 - Verixi”

Thanks for any solution!!!

Assuming, that you can handle the bridge and other peices, here is the queue piece. This will work on ROS 6.7:

/queue simple
add max-limit=10M/10M name=Example queue=pcq-upload-default/pcq-download-default target=10.0.0.0/24

I think that this isn’t the correct solution, is this possible? When i do a speedtest with 2 pc’s (at the same time) i have 5mbit up and 5mbit down on each. I want to limit the speed so that the maximum speed per ip is 10mbit, not in total for an interface. The uplink (WAN) is 1Gbit, I just don’t want that my users download at 1Gbit.

There are two ways to do that.
i) add multiple queues (1 per IP). (which doesn’t seem like a good idea to me.)
ii) define two new PCQs queue types. (1 for download & 1 for upload)

I use winbox most of the times .. so don’t remember the exact cli commands.
but in winbox .. you’ll have to go to Queues → Queue Types → Add(+)
give it a name: say.. 10M-Download, kind=pcq, rate=10M, Classifier=DstAddress .. for rest defaults are OK.
add another one:
name = 10M-Upload, kind=pcq, rate=10M, Classifier=SrcAddress.

Now go to “simple queues” add a new one..
name it whatever you want.. with target address being the subnet you want to apply limits on. (LEAVE UPLOAD/DOWNLOAD LIMITS TO UNLIMITED ON THIS TAB).

and in advance tab of this queue, change the queue type to the one you’ve just created.
Hit apply/ok and you’re done. :slight_smile:

Post back for any clarifications.

In the Simple Queue the upload/download max limit MUST be specified. This is the limit for ALL users. The PCQ needs to know how much available bandwidth it has. In the PCQ Rate you specify limit per ONE user (maximal available data rate of each sub-stream).

Example: If the max. download limit is 10Mb, and you specify 3Mb in the PCQ Rate, every user will get max. 3Mb, even if in that moment the internet connection can give him more than that. If You type 0 in the PCQ Rate, PCQ will divide the 10Mb max. limit equally between users.

Read this wiki for detailed explanation.
For a precise PCQ queue behavior, I would suggest that You specify both → the max. limit and the PCQ Rate limit(not 0).

So this solution isn’t correct:

http://pastebin.com/jNmr8e6A

No. You wrote that your download speed is 1Gbit(1000Mb). If that really is the case, then 1000Mb is your download max. limit. If your upload speed is also 1000Mb, then this is Your upload max limit. Your PCQ upload/download queues seem ok. Just add them in the Advanced tab under Queue Type.
Look at the pictures in the attachment.
SQ-General.png
SQ-Advanced.png

I do not understand what us happening.
I have the router with default configuration and I just add limits like you mentioned.
I have only one bridge and this I put in “target”.
The limits is working great, metered with 3 devices.
But sometimes it is not working and I can not see the traffic in queues exept some small kbps.

I change the target from bridge and I put ip range 192.168.88.0/24 and is workind well.
I remove the mikrotik from the wall and the limits is not working.
I removed again and is working.
What is happening??

Perhaps this will do the trick for you:

Open Winbox and login to Mikrotik then run the following script in the terminal.

What it does is limit all devices in the 192.168.1.0/24 range individually to 2Mbps up and down.

You can modify this script to meet your requirements, and network layout.

Enter speed limit up/down on pcq-rate.
Modify “target=192.168.1.0/24” to match your local / client network range.

# Limit Bandwidth of each IP in an entire subnet:
/queue type
add kind=pcq name=pcq-upload-custom pcq-classifier=src-address pcq-rate=2M
add kind=pcq name=pcq-download-custom pcq-classifier=dst-address pcq-rate=2M
/queue simple
add name=Throttle-Each queue=pcq-upload-custom/pcq-download-custom \
target=192.168.1.0/24

thank you very much.
I tried but it is not working.
it is very weird because im getting ip from the range of the simple queue and the router have the default configuration.

Is the fasttrack on? If yes it prevents the queues to work. Switch it off.

Thank you
The problem appeared in 2 mikrotik boxes with default configuration.
i had reset the router and i configured again and now is working.

What is the “fasttrack” and were i can find it?

By the way i have a very small line 1Mbit / 4Mbit .
i have limit the bandwith now to 500k / 2M .
i want to try to give all the bandwith and leave mikrotik to give equal to users.
is this better idea does this function workin well?
What is the simpest option to do that?

I realize this post is nearly a year old and I’m not the original poster, but this solved my issue. Thank you!