Monthly Archives: March 2012

Block spammers by IP

If your website is being attacked by spammers, you may want to block those users from your website. first thing we will do is to see how many connection by IP we have in our server, we will do this using netstat.

  1.  
  2. netstat -ntu | awk ‘ $5 ~ /^[0-9]/ {print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
  3.  

Once we have the IP address to block, we will use .htaccess to block those ip address like:

  1.  
  2. order allow,deny
  3. deny from 127.0.0.1
  4. deny from 127.0.0.2
  5. deny from 127.0.0.3
  6. allow from all
  7.