How to reliably limit the amount of bandwidth your room mate or bad office colleague uses

Update: It seems I’ve created a monster. I’ve had my first two Google searchers arrive on this blog entry searching for “limit roomate downloading” and “netgear limit roomate”. Well after years of experimenting with QoS this is the best method I’ve found to do exactly that, so enjoy.

For part of the year I’m on a rural wifi network that, on a good day, gives me 3 megabits per second download speed and 700kbps upload speed. I’ve tried multiple rural providers, had them rip out their equipment because of the packet loss (that means you Skybeam), I’ve shouted at Qwest to upgrade the local exchange so we can get DSL, but for now I’m completely and utterly stuck on a 3 megabits downlink using Mile High Internet.

I have an occasional room-mate, my nephew, who downloads movies on iTunes and it uses about 1.5 to 3 megabits. I’ve tried configuring quality of service (QoS) on various routers including Netgear and Linksys/Cisco and the problem is that I need a zero latency connection for my SSH sessions to my servers. So while QoS might be great if everyone’s using non-realtime services like iTunes downloads and web browsing, when you are using SSH or a VoIP product like Skype, it really sucks when someone is hogging the bandwidth.

The problem arises because of the way most streaming movie players download movies. They don’t just do it using a smooth 1 megabit stream. They’ll suck down as much as your connection allows, buffer it and then use very little bandwidth for a few seconds, and then hog the entire connection again. If you are using SSH and you hit a key, it takes a while for the router to say: “Oh, you wanted some bandwidth, ok fine let me put this guy on hold. There. Now what did you want from me again? Hey you still there? Oh you just wanted one real-time keystroke. And now you’re gone. OK I guess I’ll let the other guy with a lower priority hog the bandwidth again until you hit another keystroke.”

So the trick, if you want to effectively deal with the movie downloading room-mate is to limit the amount of bandwidth they can use. That way netflix, iTunes, youtube, amazon unbox or any other streaming service has to use a constant 1 megabit rather than bursting to 3 megabits and then dropping to zero – and you always have some bandwidth available without having to wait for the router to do it’s QoS thing.

Here’s how you do it.

First install DD-WRT firmware on your router. I use a Netgear WNDR3300 router and after using various Linksys/Cisco routers I swear by this one. It has two built in radios so you can create two wireless networks, one on 2Ghz and one of 5Ghz. It’s also fast and works 100% reliably.

Then look up your router on dd-wrt’s site and download DD-WRT for your router and install it. I use version “DD-WRT v24-sp2 (10/10/09) std – build 13064”. There are newer builds available, but when I wrote this this was the recommended version.

Once you’re all set up and you have  your basic wireless network with DD-WRT, make sure you disable QoS (it’s disabled by default).

Then configure SSH on DD-WRT. It’s a two step process. First you have to click the “Services” tab and enable SSHd. Then you have to click the Administration tab and enable SSH remote management.

Only the paid version of DD-WRT supports per user bandwidth limits, but I’m going to show you how to do it free with a few shell commands. I actually tried to buy the paid version of DD-WRT to do this, but their site is confusing and I couldn’t get confirmation they actually support this feature. So perhaps the author can clarify in a comment.

Because you’re going to enter shell commands, I recommend adding a public key for password-less authentication when you log in to DD-WRT. It’s on the same DD-WRT page where you enabled  the SSHd.

Tip: Remember that with DD-WRT, you have to “Save” any config changes you make and then “Apply settings”. Also DD-WRT gets confused sometimes when you make a lot of changes, so just reboot after saving and it’ll unconfuse itself.

Now that you have SSHd set up, remote ssh login enabled and hopefully your public ssh keys all set up, here’s what you do.

SSH to your router IP address:

ssh root@

Enter password.

Type “ifconfig” and check which interface your router has configured as your internal default gateway. The IP address is often The interface is usually “br0”.

Lets assume it’s br0.

Enter the following command which clears all traffic control settings on interface br0:

tc qdisc del dev br0 root

Then enter the following:

tc qdisc add dev br0 root handle 1: cbq \
avpkt 1000 bandwidth 2mbit

tc class add dev br0 parent 1: classid 1:1 cbq \
rate 700kbit allot 1500 prio 5 bounded isolated

tc filter add dev br0 parent 1: protocol ip \
prio 16 u32 match ip dst flowid 1:1

tc filter add dev br0 parent 1: protocol ip \
prio 16 u32 match ip src flowid 1:1

These commands will rate limit the IP address to 700 kilobits per second.

If you’ve set up automatic authentication and you’re running OS X, here’s a perl script that will do all this for you:


my $ip = $ARGV[0];
my $rate = $ARGV[1];

$ip =~ m/^\d+\.\d+\.\d+\.\d+$/ &&
$rate =~ m/^\d+$/ ||
die “Usage:\n”;

$rate = $rate . ‘kbit’;

print `ssh root\@ “tc qdisc del dev br0 root”`;

print `ssh root\@ “tc qdisc add dev br0 root handle 1: cbq avpkt 1000 bandwidth 2mbit ; tc class add dev br0 parent 1: classid 1:1 cbq rate $rate allot 1500 prio 5 bounded isolated ; tc filter add dev br0 parent 1: protocol ip prio 16 u32 match ip dst $ip flowid 1:1 ; tc filter add dev br0 parent 1: protocol ip prio 16 u32 match ip src $ip flowid 1:1″`;

You’ll see a few responses for DD-WRT when you run the script and might see an error about a file missing but that’s just because you tried to delete a rule on interface br0 that might not have existed when the script starts.

These rules put a hard limit on how  much bandwidth an IP address can use. What you’ll find is that even if you rate limit your room mate to 1 megabit, as long as you have 500 kbit all to yourself, your SSH sessions will have absolutely no latency, Skype will not stutter, and life will be good again. I’ve tried many different configurations with various QoS products and have not ever achieved results as good as I’ve gotten with these rules.

Notes: I’ve configured the rules on the internal interface even though most QoS rules are generally configured on an external interface because it’s the only thing that really really seems to work. The Cisco engineers among you may disagree, but go try it yourself before you comment. I’m using the Linux ‘tc’ command and the man page is here.

PS: If you are looking for a great router to install DD-WRT on, try the Cisco-Linksys E3200. It has a ton of RAM and the CPU is actually faster at 500 MHz than the E4200 which is more expensive and only has a 480 MHz CPU. It also is the cheapest Gigabit Ethernet E series router that Cisco-Linksys offers. Here is the Cisco-Linksys E3200’s full specs on DD-WRT’s site. The E3200 is fully DD-WRT compatible but if you are lazy and don’t want to mess with DD-WRT, check out the built in QoS (Quality of Service) that the E3200 has built in on this video.

60 thoughts on “How to reliably limit the amount of bandwidth your room mate or bad office colleague uses

  1. hello,
    we tested the rules limiting download and works properly but the rules limiting upload not working nor for Mac or by ip. Can you help us?

  2. what happens if there is a file server on the network? will this also rate-limit the file transfer?

  3. Thanks for an easy to follow howto. The tc’s manpage is dense and it great to have a useful application. I would like to make a change to limit the bandwidth everyone on a particular subnet (my guest wifi is on a different subnet). Is it possible to replace the IP address by a netmask in the tc command lines? Thanks in advance!

  4. nice commands … However this is NOT needed anymore in the new dd-wrt firmware versions …. I am using dd-wrt v24-sp2 (05/27/14) build 24160 … Under QoS , you have full control on bandwidth limit for upload and download for either aggregated WAN interface , or per client, per MAC address , service , just full control over bandwidth limitation ….
    My dd-wrt router is the second router which is cascaded to my main (fast router), and I am using the aggregated WAN limit to avoid limiting users one by one , so guests and bandwidth abusing users are allowed only to access dd-wrt router

    P.s. My home router has bandwidth of 24MB, while I limited the dd-wrt router with 512kbps only …. It’s working like charm 🙂

  5. you’re truly a just right webmaster. The site loading speed is incredible. It kind of feels that you are doing any distinctive trick. In addition, The contents are masterpiece. you’ve performed a magnificent task in this subject! faegeekbagkg

  6. Enabling SSH Remote Management is not needed and can open your router to possible attacks. I wouldn’t recommend it.

    Awesome blog post. Helped me throttle a friend who is staying with me for a while. He’s a Steam fan and downloads new games daily and it was dragging my 5Mbit DSL connection threw the mud. This seems to be working beautifully. Thanks!

  7. Hey I wanted to know what are the commands for setting QoS on basis of services? Please help me

  8. How to provide the limited data for IP addresses to the month? IS ANY ONE HELP ME ON THIS Section?

  9. Hi,
    I’m not sure if anyone is still reading these comments but I had a questions I was hoping someone could help me answer.
    I have several hosts in my network that I would like to limit the bandwidth so that no one can exceed 3mbits so that one person doesn’t hog the entire line.
    Should I just make another filter entry for each IP and put them all under the same class or do I have to create a separate class and/or qdisc for each IP that I want to limit?

  10. How do you apply it for ip ranges? Do I have to execute the commands every time for each ip?

  11. How do you apply this for ip ranges? Do I have to redo the commands every time for each ip address?

  12. My satellite ISP has a 30 day usage limit of 10gb, which is enough for my needs, but when guests visit I’d like to limit their total usage to 100mb per day or less.

    Does anyone know if this can be accomplished?

  13. Is there a way to determine if this change to my router is working? All of the commands executed without an error so I am assuming everything is working. Right?

  14. Hi Mark, awesome tutorial!, listen we have are a small company in Mexico City and I need your help to to this, I tried to follow the steps mentioned here but when I run this command “tc qdisc del dev br0 root” it throws “RTNETLINK answers no such file or directory” anyways, I was wondering if you could help us via skype of course we will pay for your advice, could be anytime any day just let me know, my email is

    Thanks in advance!

  15. Sir i am in a hostel. our wifi is hacked by one of our colleague. only his laptop has wifi connectivity 24*7. I am not able to connect. i think he has hacked our wifi for sure. please help me i am in deep trouble

    • Try net cut utility. U can identify his IP address and MAC too and prevent him from disconnecting you from the network.

  16. OK, I’ve run the tc commands and the router didn’t snivel, so maybe it’ll work.

    What sort of tc command can I run to check that the commands have ‘taken’, so I can be sure that my brother-in-law will be bandwidth limited when he stream sports channels when he visits us, please?


  17. Excellent tutorial, which after I’ve digested it will probably do just what I’m looking for. Many thanks Mark!

    Just one aside: I’ve printed the man page for tc and have to say that whilst I have some experience with Linux, the tc command seems pretty opaque!

  18. I am running a cyber cafe with 10 computers, DIR 615 dlink router and a wimax MODEM for internet. All the computers are connected to the router through wirelless cards. How can I limit the download and upload bandwith through my rouuter? THANKS in advance.

  19. Hey, nice tutorial 😀 I wish my Router supported it :/ My Italian room mate has been hogging the bandwidth for ages.

    Ignore the stupid, arrogant haters in above posts 😛

    You sure know your stuff!

  20. Great info – thanks! No good deed goes unpunished – I have two questions. First, do you know how to apply the limit to the upload speed? Second, is there a line to remove the rule, aside from just increasing the limit?

    Thanks again!

  21. What a surprise.

    Author uses technical terms unknown to non-techies … And lo and behold, author runs a technology company.

    What a surprise.

    • It’s not even that technical, a subject like this requires a slightly techinical answer.

      Have you considered instead of moaning about the lingo/jargo used. Actually Googling (that’s how you go here right) the lingo and consider reading. There is an ever increasing number of lazy people always wanting the quick solution with minimal learning. The author could not of made it any easier for you.

      Thanks Mark, brilliant solution to quite a complex problem. I would ignore comments from the “sloth-like” people.

  22. Now how to introduce packet delays and the like? That would be cool to know.

  23. HEY! CAN SOMEONE HELP ME! HOW CAN I DISABLE THIS LIMITATION, CAUSE MY BROTHER USED THIS “hogging of bandwidth”. I have DL SPEED of 400-2mb before but now it fell to 20kbps. Were sharing a Router…..


  24. Hi, nice tutorial! I have one question – since our line is asynch in that we have 4Mbps down and 512kbps up, how would I limit the down speed to700kbps and the up speed to 100 kbps?

    Thanks again, cool article!

  25. I stumbled on your post and this is exactly what i am looking for. however, i can’t figure out

    SSH to your router IP address:
    ssh root@
    Enter password.
    Type “ifconfig” and check which interface your router has configured as your internal default gateway. The IP address is often The interface is usually “br0″.

    How do i get there? I set up my private key and can connect thru WinSCP following the dd-wrt wiki.

  26. hi
    i have DIR-615(Dlink) and loaded DD-WTR for it.
    i limited bandwidth with tc commands but
    cleared all limitation when i turn off router

  27. hiii in my hostel someone is hacking the speed of wifi and his speed is of 1mbps but here in my laptop it is only 3 kbps .. plz help me what to do .. m cnfused
    should i use any software..
    or can anybody tell me what is that guy using and what is he doing … plz help me

  28. Great idea ! i would like to ask something more.
    In my situation , i am in quite identical to yours, i have a 2 gig avalability at my laptop from a 30 gig at the model from the service provider. So i don’t ask help for that aspect, nothing can be done, already tryed. What i am concernng about is there is only one ”cvlient” me, but i have a constant 3 other pc that use my bandwith limit for free. ( it is accepted that way ) But my problem is that i have a limited bandwith download after what i have a penality fee by each gig over what make an expensive fine by the end of the month. Guess WHAT ? nobody take exess bandwith lolll ! so as i can’t see what every one use as programme and download, i don’t want to slowdown them but to install a ”filtering download bandwith limit for EACH one i add on my network ( under my rooter..dd-wrt linksys modelwrt54G/GL/GS.) Is there a setting or a command lines that would settle me for that ? That way, what ever or when ever they use the bandwith,when reached their each specified limit, their connection will be stop until the next paramater. ( ex: 500mb/day or 3 gig a week or 12 gig / month ) I would b able to have a better control of the bandwith regardless of anybody use,just by the mac adress download limit. Thank’s a lot

    Notify me if something is confusing in my explanation

  29. sorry to bother you, i was trying to do the same but with a liksys wrt54g2 but all i get is:

    root@DD-WRT:~# tc qdisc del dev br0 root
    RTNETLINK answers: No such file or directory
    root@DD-WRT:~# tc qdisc add dev br0 root handle 1: cbq \
    > avpkt 1000 bandwidth 6mbit
    RTNETLINK answers: Invalid argument
    root@DD-WRT:~# tc class add dev br0 parent 1: classid 1:1 cbq \
    > rate 700kbit allot 1500 prio 5 bounded isolated
    RTNETLINK answers: No such file or directory
    root@DD-WRT:~# tc filter add dev br0 parent 1: protocol ip \
    > prio 16 u32 match ip dst flowid 1:1
    RTNETLINK answers: Invalid argument
    root@DD-WRT:~# tc filter add dev br0 parent 1: protocol ip \
    > prio 16 u32 match ip src flowid 1:1
    RTNETLINK answers: Invalid argument

    any ideas?
    thanks in advance

  30. If I want to do this for a handful of different ips that are not in any particular range, is that possible?

  31. Nice article, exactly what I’m looking for, except I am having a problem with step 2:

    root@DD-WRT:~# tc class add dev br0 parent 1: classid 1:1 cbq \
    > rate 1kbit allot 1500 prio 5 bounded isolated
    RTNETLINK answers: No such file or directory

    Anyone have any suggestions?

  32. actually this information is useful for me but i want to restrict all user who connect with my router in my office so who to do this for all user

    please give me solution
    as soon as possible it’s argent

  33. Perhaps you can tell us what each line of command means. I like to know what I’m doing. Also what if I am using a 15 Mbps internet connection. Will the commands be different? Lastly, how can I undo this. Thanks.

  34. Hi
    Great tutorial. It seems like it is exactly what I have been looking for….however, beeing a newbie in this field, I need a little more guidance to get all the way home.

    quote: ” Because you’re going to enter shell commands, I recommend adding a public key for password-less authentication when you log in to DD-WRT.”
    How do I add a public key?

  35. Hi, Need a solution:-
    I have a belkin router in my home, my room mate have limited my bandwidth allocation, how can i reset the same. and get the access to the full bandwidth?
    Thank you in advance

  36. This is GREAT!!! The only problem I have is doing it by IP address since it’s normally assigned dynamically. My son’s computer is normally the bandwidth hog since he’s streaming movies and conducting internet life on a near 24/7 basis. I’ve gone so far as to create a separate wireless network for him and allow him to connect *only* to that WiFi network. I configured rules to prevent his network from being able to see any of the other networks so have essentially carved out a network that he and his friends can connect to. I’d *really* (emphasis on REALLY) love to be able to limit this network to a certain amount of bandwidth. (Think of it as a guest network per se.) If that isn’t possible, perhaps limiting by MAC address would be the second best option. I can’t tell you how many times my network has gone to a crawl (SSH sessions disconnecting, all hell breaking loose) because one of his friends comes over and is running a P2P program that sucks all the available bandwidth. I have 24Mbps download and 6Mbps upload on a pretty consistent basis so my network rocks – it just gets abused…

    I’ve created a restriction policy and put it in place based on MAC address. I add his friends computers and apply the setting. BOOM! Internet is back to stable for me and there’s weeping and wailing coming from his bedroom. I hate to completely cut him off so just limiting him to 1-2Mbps would be ideal.

    Please let me know if you can think of anyway to achieve this great feat!


    • Yes you can limit it by making a different segment for him. For example, if your complete network is 192.168.1./24 like the examples given, you can set static IPs in the dhcp server of the router within the trusted range of, and then set the dhcp dynamic range to 128+

      Then in the tc filter commands, use instead of a specific IP address. That is shorthand for with a netmask of That makes all IPs 128 and above restricted to the limit set. And since that is the dynamic range given by the dhcp server, only trusted devices you assign IPs below 128 will not be subject to the limit. You can get fancy and add multiple limits, using 1:2 instead of 1:1 as well.

      • Hello. I am about to buy a Netgear WNDR3300 router to apply this guide.
        My goal is to limit the bandwidth use of an Ipod touch and a PC connected wirelessly to my current router.

        My network also assigns random IP addresses to each device. I want to use your method to create two divisions of IPs in the DHCP server to help me set apart throttled devices from restriction-free ones.

        Could you explain with a bit more detail how to create these “groups” and how do I assign static IPs to restriction-free devices?

        I want to understand how this is going to work before I buy the router.


        • Look at setting up Vlans. Then apply the above to the Vlan you want. EX: Vlan1 is 192.168.2.x and Vlan3 is 192.168.3.x

    • DD WRT has a function that allows the DHCP server to always issue a specific PC with the same IP address dynamically. This is done by associating a MAC address with a static IP lease. This can be set under the Services tab > DHCP Server > Static Leases. You put in the MAC address and the desired IP address (which should be out of range of the DHCP server) and that IP will automatically be assigned to that a specific PC whenever it connects.

      This would then allow you to follow Mark’s instructions above.

Comments are closed.