Skip to contentSkip to conversation

help using tc

LARTC David Ulevitch 1 participant 1 message Nov 9, 2001

lore
Share & tools
lore
#0 lore raw

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:[email protected]
Founder, EveryDNS.net http://www.everydns.net

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/