home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / iproute / examples / SYN-DoS.rate.limit < prev   
Encoding:
Text File  |  2004-04-15  |  1.6 KB  |  50 lines

  1. #! /bin/sh -x
  2. #
  3. # sample script on using the ingress capabilities
  4. # this script shows how one can rate limit incoming SYNs
  5. # Useful for TCP-SYN attack protection. You can use
  6. # IPchains to have more powerful additions to the SYN (eg 
  7. # in addition the subnet)
  8. #
  9. #path to various utilities;
  10. #change to reflect yours.
  11. #
  12. IPROUTE=/root/DS-6-beta/iproute2-990530-dsing
  13. TC=$IPROUTE/tc/tc
  14. IP=$IPROUTE/ip/ip
  15. IPCHAINS=/root/DS-6-beta/ipchains-1.3.9/ipchains
  16. INDEV=eth2
  17. #
  18. # tag all incoming SYN packets through $INDEV as mark value 1
  19. ############################################################ 
  20. $IPCHAINS -A input -i $INDEV -y -m 1
  21. ############################################################ 
  22. #
  23. # install the ingress qdisc on the ingress interface
  24. ############################################################ 
  25. $TC qdisc add dev $INDEV handle ffff: ingress
  26. ############################################################ 
  27.  
  28. #
  29. # SYN packets are 40 bytes (320 bits) so three SYNs equals
  30. # 960 bits (approximately 1kbit); so we rate limit below
  31. # the incoming SYNs to 3/sec (not very sueful really; but
  32. #serves to show the point - JHS
  33. ############################################################ 
  34. $TC filter add dev $INDEV parent ffff: protocol ip prio 50 handle 1 fw \
  35. police rate 1kbit burst 40 mtu 9k drop flowid :1
  36. ############################################################ 
  37.  
  38.  
  39. #
  40. echo "---- qdisc parameters Ingress  ----------"
  41. $TC qdisc ls dev $INDEV
  42. echo "---- Class parameters Ingress  ----------"
  43. $TC class ls dev $INDEV
  44. echo "---- filter parameters Ingress ----------"
  45. $TC filter ls dev $INDEV parent ffff:
  46.  
  47. #deleting the ingress qdisc
  48. #$TC qdisc del $INDEV ingress
  49.