#!/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...
sudo /sbin/tc qdisc del root dev eth0
echo Setting root qdisc...
sudo /sbin/tc qdisc add dev eth0 root handle 1: htb
echo Setting bandwidth classes...
sudo /sbin/tc class add dev eth0 parent 1: classid 1:1 htb rate 1mbit ceil 100gbit
sudo /sbin/tc class add dev eth0 parent 1:1 classid 1:10 htb rate 1gbit ceil 1gbit
echo Creating filters...
sudo /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
sudo /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...
sudo /sbin/tc qdisc add dev eth0 parent 1:10 handle 20: sfq perturb 10