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.

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

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

  2. order allow,deny
  3. deny from
  4. deny from
  5. deny from
  6. allow from all