#!/bin/sh
# Traffic shaping script
# ---------------------------------------------------------------------
# Limits upload/download speed to the lan to 1gbit/s, leaving speeds
# outside the LAN unaffected
# ---------------------------------------------------------------------
# Thanks to iponeverything, fwre01, spr- of http://ubuntuforums.org/
# ---------------------------------------------------------------------
# Starting with a clean slate
echo Removing any previously set rules...
/sbin/tc qdisc del root dev eth0
echo Setting root qdisc...
/sbin/tc qdisc add dev eth0 root handle 1: htb
echo Setting bandwidth classes...
/sbin/tc class add dev eth0 parent 1: classid 1:1 htb rate 1mbit ceil 100gbit
/sbin/tc class add dev eth0 parent 1:1 classid 1:10 htb rate 250mbit ceil 250mbit
echo Creating filters...
/sbin/tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.1.1/24 flowid 1:10
/sbin/tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 192.168.1.1/24 flowid 1:10
echo Finishing...
/sbin/tc qdisc add dev eth0 parent 1:10 handle 20: sfq perturb 10