ISP Traffic Shaping SLA Script
For a linux based router:
#!/bin/bash
IF=eth2
#clean up any current config
tc qdisc del dev eth2 root
#set up the interface, and set packet size
#(1000) and bandwidth (for shaping calcs)
#this is typically the inside NIC card interface,
#not the outside (Upstream facing) nic
tc qdisc add dev $IF root handle 1: cbq avpkt 1000 bandwidth 100mbit
#create a 512 kbit class
tc class add dev $IF parent 1: classid 1:1 cbq rate 512kbit allot 1500 prio 5 bounded isolated
#create a 1MBit class
tc class add dev $IF parent 1: classid 1:2 cbq rate 1MBit allot 1500 prio 5 bounded isolated
#create a 2MBit class
tc class add dev $IF parent 1: classid 1:3 cbq rate 2MBit allot 1500 prio 5 bounded isolated
#create a 3MBit class
tc class add dev $IF parent 1: classid 1:4 cbq rate 3MBit allot 1500 prio 5 bounded isolated
#create a 4MBit class
tc class add dev $IF parent 1: classid 1:5 cbq rate 4MBit allot 1500 prio 5 bounded isolated
#-------------CUSTOMER SLA's------------#
#customer 1-1 mbit
#dst in this case is the customer's ip address
tc filter add dev $IF parent 1: protocol ip prio 16 u32 match ip dst 10.10.31.103 flowid 1:2
#customer 2-2 mbit
tc filter add dev $IF parent 1: protocol ip prio 16 u32 match ip dst 10.10.31.104 flowid 1:3
#/------------CUSTOMER SLA's-----------#
#start shaping the classes
tc qdisc add dev $IF parent 1:1 sfq perturb 10
tc qdisc add dev $IF parent 1:2 sfq perturb 10
tc qdisc add dev $IF parent 1:3 sfq perturb 10
tc qdisc add dev $IF parent 1:4 sfq perturb 10
tc qdisc add dev $IF parent 1:5 sfq perturb 10
Comments
Post a Comment
If you are asking me a question via comments, please be patient.