How to stop pesky spam by blocking IP addresses from visiting your blog
Wow, that’s a long title, but it’s worth it! This is just a quick blog post really to vent a bit of pseudo-anger.
I have been getting a hell of a lot of spam from a certain IP address, I’m not one to point fingers, so I won’t tell you what it is *cough* 126.96.36.199 *cough*. And I’m talking about 4 or 5 spam comments an hour (which I know, on the grand scheme of things is nothing, but it’s quite over-whelming for a small time blogger like myself!). So either it’s a bot, or a person who has an extremely large supply of non-prescription drugs in his garage. Either way, I don’t want them posting spam comments on my blog. If it’s a bot, it won’t really care; if it’s a real person, f@*% you, if all you can do is post spam comments, then I don’t want you reading my blog anyway!
I’m simply going to use my great pal
.htaccess to deny access to my site from the spamming IP. I realise that this is not a great solution, after all, it’s unlikely that you’ll be able to keep on-top of every single IP address of spammers, but it’s an insight into the principles, and a great way of getting rid of single troublesome IPs.
So here’s the code:
Deny from 188.8.131.52
Allow from all
Which is as easy to understand as it looks – just give it the IP you don’t want to have access to your site, and tell apache to deny access. This is actually remarkably powerful, you can use it to conditionally serve CSS for different browsers (based on browser string), stop image hot-linking, and much much more.
Dude, just use Akismet
Yeah, I know, you’re right, Akismet is awesome! If you don’t have it installed on your blog, you should. It checks a huge (and frequently updated) database to see if a new comment looks like spam, and if so, puts it into a spam queue. But I just like to keep on top of my spam queue and keep it empty. So getting rid of this troublesome IP will save me a bit of time and trouble :)
Have you had similar spamming IP problems? What were the addresses. Go on, name and shame!