daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest May 13th, 2014 172 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. ### basic settings - speed in bits/sec
  4. WAN_INTF=eth0
  5. WAN_UP_SPEED=2800000
  6. WAN_DOWN_SPEED=28000000
  7.  
  8. ### advanced settings
  9. TQDISC=fq_codel
  10.  
  11. # Dave Taht's recommendation:
  12. #   less than 40mbit: 300
  13. #   otherwise: 1514
  14. FQ_CODEL_QUANTUM_UP=300
  15. FQ_CODEL_QUANTUM_DOWN=300
  16.  
  17. # Dave Taht's recommendation:
  18. #   less than 3mbit: 15ms
  19. #   otherwise: 5ms
  20. FQ_CODEL_TARGET_UP=15ms
  21. FQ_CODEL_TARGET_DOWN=5ms
  22.  
  23. # Dave Taht's recommendation:
  24. #   less than 40mbit: 1500
  25. #   otherwise: higher (e.g., 8000 or higher for 100mbit etc.)
  26. HTB_QUANTUM_UP=1500
  27. HTB_QUANTUM_DOWN=1500
  28.  
  29. ### configurable knobs end here
  30.  
  31. TQDISC_OPTS_UP=
  32. TQDISC_OPTS_DOWN=
  33. if [ "$TQDISC" == fq_codel ]; then
  34.     TQDISC_OPTS_UP+="quantum $FQ_CODEL_QUANTUM_UP "
  35.     TQDISC_OPTS_UP+="target $FQ_CODEL_TARGET_UP "
  36.     TQDISC_OPTS_DOWN+="quantum $FQ_CODEL_QUANTUM_DOWN "
  37.     TQDISC_OPTS_DOWN+="target $FQ_CODEL_TARGET_DOWN "
  38. fi
  39.  
  40. WAN_IFB="ifb_${WAN_INTF}"
  41. TC=/sbin/tc
  42. IP=/sbin/ip
  43.  
  44. $TC qdisc del dev $WAN_INTF root >/dev/null 2>&1
  45. $TC qdisc del dev $WAN_INTF ingress >/dev/null 2>&1
  46. $TC qdisc del dev $WAN_IFB root >/dev/null 2>&1
  47.  
  48. [ "$1" == clear ] && exit 0
  49.  
  50. $TC qdisc add dev $WAN_INTF root handle 1: htb default 10
  51. $TC class add dev $WAN_INTF parent 1: classid 1:1 \
  52.     htb quantum $HTB_QUANTUM_UP \
  53.     rate $WAN_UP_SPEED ceil $WAN_UP_SPEED
  54. $TC class add dev $WAN_INTF parent 1:1 classid 1:10 \
  55.     htb quantum $HTB_QUANTUM_UP \
  56.     rate $WAN_UP_SPEED ceil $WAN_UP_SPEED
  57. $TC qdisc add dev $WAN_INTF parent 1:10 handle 100: $TQDISC $TQDISC_OPTS_UP
  58.  
  59. $IP link add $WAN_IFB type ifb >/dev/null 2>&1
  60. $TC qdisc add dev $WAN_IFB root handle 1: htb default 10
  61. $TC class add dev $WAN_IFB parent 1: classid 1:1 \
  62.     htb quantum $HTB_QUANTUM_DOWN \
  63.     rate $WAN_DOWN_SPEED ceil $WAN_DOWN_SPEED
  64. $TC class add dev $WAN_IFB parent 1:1 classid 1:10 \
  65.     htb quantum $HTB_QUANTUM_DOWN \
  66.     rate $WAN_DOWN_SPEED ceil $WAN_DOWN_SPEED
  67. $TC qdisc add dev $WAN_IFB parent 1:10 handle 100: $TQDISC $TQDISC_OPTS_DOWN
  68.  
  69. $IP link set $WAN_IFB up
  70. $TC qdisc add dev $WAN_INTF handle ffff: ingress
  71. $TC filter add dev $WAN_INTF parent ffff: \
  72.     protocol all prio 10 u32 match u32 0 0 flowid 1:1 \
  73.     action mirred egress redirect dev $WAN_IFB
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top