depicus

changing the digital world one bit at a time...

Blants (noun) the rants of a blogger

  1. Use IPTABLES to block those pesky spammers.

    August 29, 2014 by The Man

    I recently had a spate of attacks on my site from bots trying to find weaknesses in WordPress and MySQL. I mainly just log and report but after a while of the same IP over and over I decided to just block it. So here is how to block by IP addresses in Ubuntu or any Linux distro.

    sudo iptables -I INPUT -s 61.160.212.57 -j DROP

    and if you want to do a range

    sudo iptables -I INPUT -s 61.160.212.0/24 -j DROP

    would block everything in 61.160.212.x

    And yes this is the real spammers ip address out of China. Quite prolific.

    If you installed iptables-persistent you can use

    sudo /etc/init.d/iptables-persistent save

    to save your iptables.

    Update

    Because I keep forgetting, here is another way to save if you use iptables-persistent

    sudo dpkg-reconfigure iptables-persistent