Instantly share code, notes, and snippets.

Embed
What would you like to do?
#! /bin/bash
#
# Restore the tc configuration
# This Traffic Control configuration allows a better use of the ADSL outbound
# traffic.
#
# Router configuration
DEV=eth1
QLEN=100
MTU=1492
RATEUP=420 # kbit
RATEMIN=10 # kbit
DEFAULT_PRIO=15
# Get lsb functions
. /lib/lsb/init-functions
# Flush current configuration
log_begin_msg "Flushing tc configuration..."
tc qdisc del dev $DEV root
log_end_msg $?
# Set new configuration
log_begin_msg "Setting tc configuration..."
ip link set dev $DEV qlen $QLEN mtu $MTU
tc qdisc add dev $DEV root handle 1: htb default $DEFAULT_PRIO
tc class add dev $DEV parent 1: classid 1:1 htb rate ${RATEUP}kbit
tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 0
tc class add dev $DEV parent 1:1 classid 1:11 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 1
tc class add dev $DEV parent 1:1 classid 1:12 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 2
tc class add dev $DEV parent 1:1 classid 1:13 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 3
tc class add dev $DEV parent 1:1 classid 1:14 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 4
tc class add dev $DEV parent 1:1 classid 1:15 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 5
tc class add dev $DEV parent 1:1 classid 1:16 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 6
tc class add dev $DEV parent 1:1 classid 1:17 htb rate ${RATEMIN}kbit ceil ${RATEUP}kbit prio 7
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:11 handle 11: sfq perturb 10
tc qdisc add dev $DEV parent 1:12 handle 12: sfq perturb 10
tc qdisc add dev $DEV parent 1:13 handle 13: sfq perturb 10
tc qdisc add dev $DEV parent 1:14 handle 14: sfq perturb 10
tc qdisc add dev $DEV parent 1:15 handle 15: sfq perturb 10
tc qdisc add dev $DEV parent 1:16 handle 16: sfq perturb 10
tc qdisc add dev $DEV parent 1:17 handle 17: sfq perturb 10
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 10 fw flowid 1:10
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 11 fw flowid 1:11
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 12 fw flowid 1:12
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 13 fw flowid 1:13
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 14 fw flowid 1:14
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 15 fw flowid 1:15
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 16 fw flowid 1:16
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 17 fw flowid 1:17
log_end_msg $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment