Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- TC=/sbin/tc
- IF=wlan0
- IP=10.0.0.2
- DOWN=5mbit
- UP=4kbps
- U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"
- start() {
- $TC qdisc add dev $IF root handle 1: htb default 30
- $TC class add dev $IF parent 1: classid 1:1 htb rate $DOWN
- $TC class add dev $IF parent 1: classid 1:2 htb rate $UP
- $U32 match ip dst $IP/32 flowid 1:1
- $U32 match ip src $IP/32 flowid 1:2
- $U32 match ip protocol 17 0xff flowid 1:2
- # Source Port Range
- $U32 match ip sport 27960 0xfff8 flowid 1:2
- $U32 match ip sport 27968 0xffe0 flowid 1:2
- $U32 match ip sport 28000 0xffff flowid 1:2
- # Destination Port Range
- $U32 match ip dport 27960 0xfff8 flowid 1:2
- $U32 match ip dport 27968 0xffe0 flowid 1:2
- $U32 match ip dport 28000 0xffff flowid 1:2
- }
- stop() {
- $TC qdisc del dev $IF root
- }
- restart() {
- stop
- sleep 1
- start
- }
- show() {
- $TC -s qdisc ls dev $IF
- }
- case "$1" in
- start)
- echo -n "Starting bandwidth shaping: "
- start
- echo "done"
- ;;
- stop)
- echo -n "Stopping bandwidth shaping: "
- stop
- echo "done"
- ;;
- restart)
- echo -n "Restarting bandwidth shaping: "
- restart
- echo "done"
- ;;
- show)
- echo "Bandwidth shaping status for $IF:"
- show
- echo ""
- ;;
- *)
- pwd=$(pwd)
- echo "Usage: shaper {start|stop|restart|show}"
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement