How to use Zenfirewall with iptables

To use this list directly with iptables, you can use this script, although I recommend always using dedicated software like CSF to manage a firewall.

#!/bin/bash

LISTA_URL="https://zenfirewall.com/zenblock.txt"
CHAIN_NAME="ZENFIREWALL_BLOCKED_IPS"

# Crear cadena personalizada si no existe
iptables -N $CHAIN_NAME 2>/dev/null || iptables -F $CHAIN_NAME

# Descargar y aplicar
curl -s $LISTA_URL | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' | while read ip; do
    iptables -A $CHAIN_NAME -s $ip -j DROP
    echo "Bloqueada: $ip"
done

# Aplicar la cadena al INPUT (solo si no está ya)
iptables -C INPUT -j $CHAIN_NAME 2>/dev/null || iptables -I INPUT -j $CHAIN_NAME

echo "Total IPs bloqueadas: $(iptables -L $CHAIN_NAME -n | grep -c DROP)"

To make it permanent:

iptables-save > /etc/iptables/rules.v4