Friday 3 December 2010

DDoS blocker script

First off, try this handy command to check connected IPs:

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n


(D)DoS Deflate is a lightweight bash shell script designed to assist in the process of blocking a denial of service attack. With (D)DoS Deflate you can configure how long will the IP address will be blocked and how many connection considered as DDoS.

How to install it:
1. Open your terminal and login as root
2. Download (D)DoS Deflate:

wget http://www.inetbase.com/scripts/ddos/install.sh

3. Give execute permission to the script:

chmod 0700 install.sh

4. Install it:

./install.sh

To add your ip address as whitelist, edit this file:

nano /usr/local/ddos/ignore.ip.list

Configure (D)DoS Deflate:

nano /usr/local/ddos/ddos.conf

More details at (D)Dos Deflate


-------------------REMOVING IPTABLES RULES-------------------
With command line :

iptables -L INPUT -n --line-numbers

You'll get the list of all blocked IP. Look at the number on the left, then :

iptables -D INPUT ((line number here))

Unix command to analize access.log

The first column is number of connection attempts.

cat access.log | awk '{print $1}' | sort | uniq -c | sort -n