I return to two small scripts written for my own use: blocking an IP address and unblocking it. The aim is to make them cleaner and usable by others while keeping things simple. We add support for IPv4 and IPv6 addresses and networks, format checks and an exceptions list to avoid blocking an essential resource.
I build the functions, test and correct errors as I write. I keep two separate commands so they can be reused in different contexts, and address a trap I encountered in the first version: the same rule can appear several times in the firewall. Unblocking an address must then remove every occurrence before updating the file that holds the list.
All my links, projects and social media: https://all.bo
