I've got a server running 12.04 set up as a modem. DHCP, NAT, etc.

I need to know how to reduce the speed of a single IP on the network or set the speed of each individual IP.

My problem is my brother's GF keeps running torrents 24/7 , making my internet horribly slow. Asking her to stop hasn't worked, so now I need to control her connection.

I think my options are either limiting her to, say 4mbps down and 300kbps up... or throwing QoS at her. I've no idea how to do either.


I recommend reading the Linux Advanced Routing & Traffic Control HOWTO, in particular the examples on rate limiting a single host or netmask and a full nat solution with QoS.

Essentially you have to do the following:

  • Mark packets from that particular host in the PREROUTING chain of the mangle table
  • Set up some prioritizing or rate limiting traffic control
  • Make sure the market packets fall into the low priority resp. limited class

Untested, but something along these lines (feel free to edit if you notice a mistake):

iptables -t mangle -A PREROUTING -i eth0 -s -j MARK --set-mark 1
tc qdisc add dev ppp0 root handle 1: cbq avpkt 1000 bandwidth 10mbit 
tc class add dev ppp0 parent 1: classid 1:1 cbq rate 512kbit \
   allot 1500 prio 5 bounded isolated 
tc filter add dev ppp0 parent 1: protocol ip prio 1 handle 1 fw classid 1:1

Notice that you can't directly use tc filter to filter on the IP of that host, since the tc filter applies after NAT, so it will see your public IP, which cannot be used to differentiate the packet.

Usually you'd rate-limit upstream packets, since there you have the most control, and since on a common ADSL link the upstream is more easily saturated by p2p traffic. If you want, you can also attempt to rate-limit the downstream by deliberately dropping packets. You'd do that using another traffic control setup, this time for packets forwarded over the local network device.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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