Creating Simple Firewall Scripts
In this scenario, you need to create a text file with a list of IP addresses that you want to block. You then need to create a shell script that will read that list of IP addresses, and then create firewall rules that will block them. There are two ways that you can do this. First, there’s the hard way. And then, there’s the easy way.
The hard way consists of reading the list of addresses into a variable array, and then creating a for
loop that will create a blocking rule for each IP address that’s in the array. Okay, it’s not that hard, but it is a bit harder than we would like. (I’ll show you the easy way after I show you the hard way. That way, you’ll be more appreciative of the easy way.)
Creating an IP Address Blocking Script for Red Hat Distros
Red Hat-type distros, such as Fedora, AlmaLinux, Rocky Linux, Oracle Linux, and of course Red Hat Enterprise Linux, use firewalld
as their firewall...