[LARTC] help using tc

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello lartc,

  I am trying to control bandwidth on a server which is connected to a
  full (expensive) 10mbit port.  I want to limit the bandwidth to
  128kbps.

  I wrote this small script from the documentation I could find but it
  fails in a few places.  Any pointers would be appreciated.  The end
  goal is to have one interface (eth0) which doesn't send or accept
  packets faster then at 128kbps.

  I think some of the problem is that I use the "root" class twice.
  If there is an easier way to do this, please let me know also.
  
#!/bin/bash

echo "Setting up packet limiting";
echo "  Deleting current class";
tc qdisc del dev eth0 root;

echo "";
echo "  Setting up downstream";
tc qdisc add dev eth0 root handle 10: cbq bandwidth 10mbit avpkt 1000;
tc class add dev eth0 parent 10:0 classid 10:1 cbq bandwidth 10Mbit \
rate 128Kbit allot 1514 weight 128Kbit prio 8 maxburst 20 avpkt 1000 \
bounded;
tc qdisc add dev eth0 parent 10:100 sfq quantum 1514b perturb 15;
tc filter add dev eth0 parent 10:0 protocol ip prio 25 u32 match ip \
dst 216.218.192.162 flowid 10:100;

echo "";
echo "  Setting up upstream";
tc qdisc add dev eth0 root handle 10: cbq bandwidth 10mbit avpkt 1000;
tc class add dev eth0 parent 10:0 classid 10:1 cbq bandwidth 10Mbit \
rate 128Kbit allot 1514 weight 128Kbit prio 8 maxburst 20 avpkt 1000 \
bounded;
tc qdisc add dev eth0 parent 10:100 sfq quantum 1514b perturb 15;
tc filter add dev eth0 parent 10:0 protocol ip prio 25 u32 match ip \
src 216.218.192.162 flowid 10:100;

echo "";
echo "done";


 
Thanks,
 David Ulevitch                       mailto:davidu@xxxxxxxxxxxx
 Founder, EveryDNS.net                http://www.everydns.net     





[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux