Its unfortunate there is a rise in hackers from IP addresses originating from Asia and mainly China, as my server is not that interested in having users from china access my website or mail server I decided to block them all saving valuable resources..
This is relatively easy in Linux
If you have linux then you should be using iptables but.. what you might not have is ipset.
apt-get install ipset iptables
I create a bash script containing this:
ipset flush ipset -N china hash:net rm cn.zone wget -P . https://www.ipdeny.com/ipblocks/data/countries/cn.zone for i in $(cat cn.zone ); do ipset -A china $i; done /etc/init.d/firewall
And in my firewall script (/etc/init.d/firewall) I have added this line
/sbin/iptables -A INPUT -p tcp -m set —match-set china src -j DROP
This rule set specifically blocks china and nothing else however www.ipdeny.com contains many country lists that you can add to your block lists.
If your on openvz
Ipset will not work with IP set so on the end of your firewall rules add this
wget -P . https://www.ipdeny.com/ipblocks/data/countries/cn.zone
while read ipban do /sbin/iptables -A INPUT -s $ipban -j DROP done < cn.zone rm cn.zone
Feel free to comment on my article, I welcome any constructive critic.