First of all, if you don’t have Akismet installed, you’re just asking for trouble. I up the challenge a bit by requiring a captcha to be answered with the reCAPTCHA plugin. Even so, some spam still gets submitted and most of the time flagged as spam by Akismet. To ban repeat offenders by IP, do the following:
First, find those who repeatedly spam you. Run this SQL query:
SELECT count( * ) AS nCnt, comment_author_IP FROM wp_comments WHERE comment_approved = 'spam' GROUP BY comment_author_IP ORDER BY nCnt DESC
What you’ll get back is a table of those who spam you, ordered by how many times they spammed you:
Now you can see who spams you the most, and decide if you want to block those IPs. Let’s say I want to ban 126.96.36.199. I download my .htaccess file, and open it in a plain text editor. Then, at the very top, add:
order allow,deny deny from 188.8.131.52 allow from all
Now if the user from 184.108.40.206 comes back, they’ll get a 403/Forbidden response, banned from my site forever.
Sure, they can get another IP, but since they spammed me 6 times from this same IP, I’m sure numbers 7, 8, and 9 are right around the corner. But, not anymore.
What else do you do to stop spammers from commenting on your blog? Oh, and no spam comments, please 🙂