blockip
The blockip script is a bash script that provides a quick way to block (or unblock) IP addresses at the firewall level. The script relies on the Shorewall firewall tool being installed, as it simply adds (or removes) the IP address from Shorewall's blacklist configuration file. Once the blacklist has been altered by adding or removing IP addresses, blockip will then restart Shorewall, reloading the iptables rules.
Usage
To block IP addresses, just run the script and provide a list of IP addresses. To remove IP addresses from the blacklist, just precede each IP address with -r
Example:
blockip 10.0.0.10 10.0.0.23 -r192.168.0.111
The above command would block the IP addresses 10.0.0.10 & 10.0.0.23. It would also search through the blacklist and remove the IP address 192.168.0.111, if it is in the Shorewall blacklist.
Installation/Source
To use this script, copy the source code and save it into /usr/local/sbin/blockip as root. Give the script executable permissions and run it as root.