Advertisement
Guest User

Untitled

a guest
Nov 6th, 2012
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. # Our main interface is eth0
  2. export DEV=eth0
  3. export MAXRATE=2mbit
  4.  
  5. # Reset the qdisc
  6. tc qdisc del dev $DEV root
  7.  
  8. # We want to use htb for our qos on the server
  9. tc qdisc add dev $DEV root handle 1:0 htb r2q 100
  10.  
  11. # Remember: mbit = megabit/sec, mbps = megabyte/sec
  12.  
  13. # Add class: define main interface
  14. tc class add dev $DEV parent 1:0 classid 1:1 htb rate $MAXRATE
  15.  
  16. # Split in the interface into two main streams:
  17. # 1.2 the main one (web, nfs, cifs), but we deal with web for now, limiting to 1mbyte/sec
  18. tc class add dev $DEV parent 1:1 classid 1:2 htb rate 1mbps ceil $MAXRATE
  19. # 1.3 the out of band, service one (ssh)
  20. tc class add dev $DEV parent 1:1 classid 1:3 htb rate 0.5mbps ceil $MAXRATE
  21. tc class add dev $DEV parent 1:1 classid 1:4 htb rate 0.5mbps ceil $MAXRATE
  22.  
  23. # I'm not sure if pfifo or sfq is better for these:
  24. tc qdisc add dev $DEV parent 1:2 handle 120: pfifo limit 10
  25. tc qdisc add dev $DEV parent 1:3 handle 130: pfifo limit 10
  26. tc qdisc add dev $DEV parent 1:4 handle 140: pfifo limit 10
  27.  
  28. # Finally define which IP
  29. # Port 80
  30. tc filter add dev $DEV parent 1:0 prio 1 protocol ip u32 match ip sport 80 0xffff flowid 1:2
  31. tc filter add dev $DEV parent 1:0 prio 1 protocol ip u32 match ip sport 443 0xffff flowid 1:2
  32.  
  33. # SSH is port 22
  34. tc filter add dev $DEV parent 1:0 prio 2 protocol ip u32 match ip sport 22 0xffff flowid 1:3
  35.  
  36. #tc filter add dev $DEV parent 1:0 prio 2 protocol ip u32 flowid 1:4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement