Advertisement
Lethos

Simple DDOS Blocker

May 18th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.37 KB | None | 0 0
  1. #! /bin/bash
  2. while;;
  3.     do
  4.         for ip in `lsof -ni | grep httpd | grep -iv listen | awk '{print $8}' | cut -d : -f 2 | sort | uniq | sed s/"http->"//`;
  5.     do
  6.         noconns=`lsof -ni | grep $ip | wc -l`;
  7.         echo $ip : $noconns;
  8.  
  9.         if [ "$noconns" -gt "20" ];
  10.         then
  11.             iptables -I INPUT -s $ip -p tcp -j REJECT --reject-with tcp-reset
  12.         else
  13.             fi;
  14.     done
  15.     sleep 60
  16. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement