Blame view

decision/templates/network/bandwidth_limit_cl.sh 1.13 KB
8146dcf82   Thanasis Naskos   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #!/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