We will use a combination of iptables and ipset to create sets of IP addresses that have their
access to a host blocked. Most Linux distributions come with iptables
So, first we install the ipset package.
Next we use ipset to create two sets; one for IPv4 addresses and another for IPv6 addresses. In this example we create sets that automatically remove an IP address after one day.
Finally we set up two iptables rules to drop connections when IP addresses in the sets are matched. We use iptables for the IPv4 set and ip6tables for the IPv6 set.
At this point we are all set up, as the Phoenix plug will be responsible for adding IP addresses to the sets. However, you may want to add IP addresses manually, so here are a couple of examples.