Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have DD-WRT installed on my router and I would like to be able to restrict the bandwidth both up and down on a certain IP or Mac address. I am happy to get my hands dirty and use console.

I am sure that iptables can do this? If so could someone show me a quick example?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Well, unfortunately I haven't found a simple way to do this otherwise I would give you some examples; however, the tc command will do what you need.

Tc is a traffic shaping utility that is built into the Linux kernel. Be prepared, it isn't for the faint of heart. I recommend doing a good bit of reading about the queuing disciplines before starting.

At the least, this should give you somewhere to start:

http://www.dd-wrt.com/wiki/index.php/Tc_command

EDIT:

From that page, this link claims to have a "simple" answer:

http://lartc.org/howto/lartc.ratelimit.single.html

share|improve this answer

You can use the tc command to accomplish this. If you'd like to rate-limit a single host, there's a quick guide here:

Rate limiting a single host or netmask

If you'd like a more comprehensive setup (for example, to guarantee prioritized traffic to VoIP), DD-WRT's supports setting up QoS rules directly via its user interface. Look here:

Quality Of Service

This link from the tc creators provides a great overview of traffic shaping using their tool, which is worth a read:

The Ultimate Traffic Conditioner: Low Latency, Fast Up & Downloads

share|improve this answer

One way to do this is by placing the device in the bulk class using QoS via the web GUI then rate limiting that entire class using a cron job.

http://hardwareinsights.com/wp/2011/04/28/optimizing-your-internet-usage-with-the-qos-functionality-of-dd-wrt/

share|improve this answer

Something like this for quick example:

tc qdisc del dev br0 root
tc qdisc add dev br0 root handle 1: cbq avpkt 1000 bandwidth 10mbit
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 192.168.1.133 flowid 1:1
tc filter add dev br0 parent 1: protocol ip prio 16 u32 match ip src 192.168.1.133 flowid 1:1

Substitute 700kbit for limit you want to enforce, and 192.168.1.133 for IP you want to limit. Note that 10mbit in the first line should be near your real link speed for this to function best.

Enter it in ssh console for test. When you're happy with it, in dd-wrt put it under Administration / Commands / Save Firewall to have it start automatically on reboot / interface changes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.