Here is a quick sample bash script that you can adapt to your environment. This includes any dependencies required in Ubuntu and blocks the top 10,000 attack IPs risk level 5 in iptables