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 184.108.40.206 -j DROP
and if you want to do a range
sudo iptables -I INPUT -s 220.127.116.11/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.
Because I keep forgetting, here is another way to save if you use iptables-persistent
sudo dpkg-reconfigure iptables-persistent