Skip to main content

Firewall

Fail2ban Blocklist Tutorial

Combine Fail2ban with AntiProxies static blocklists to proactively ban known VPN, proxy and Tor IPs before they even attempt a request, at the system firewall level.

Supported formats: TXT (one IP/CIDR per line)

Steps

  1. 1

    Install Fail2ban

    Install Fail2ban with apt install fail2ban or yum install fail2ban. It uses iptables/nftables under the hood.

  2. 2

    Create a custom jail

    Add a jail configuration that loads a static ban file rather than watching log files. Fail2ban can ban IPs via its action mechanism even without log parsing.

  3. 3

    Write an action file

    Create a custom action that reads from the AntiProxies blocklist and uses iptables to block each IP.

Need the blocklist files?

The annual license includes every format and monthly data releases.

Get the complete lists Inspect sample data

Custom jail config

Fail2ban jail that loads a static IP ban list on startup.

/etc/fail2ban/jail.d/antiproxies.conf
[antiproxies]
enabled  = true
filter   = antiproxies
action   = antiproxies-blocklist
logpath  = /etc/fail2ban/blocklists/blocked_ips.txt
maxretry = 1
findtime = 86400
bantime  = -1

Custom action file

Action that creates an iptables chain for AntiProxies bans.

/etc/fail2ban/action.d/antiproxies-blocklist.conf
[Definition]
actionstart = iptables -N f2b-antiproxies
              iptables -A INPUT -j f2b-antiproxies
              # Pre-load all IPs from blocklist
              while IFS= read -r ip; do
                [[ -z "$ip" || "$ip" == "#"* ]] && continue
                iptables -A f2b-antiproxies -s $ip -j DROP
              done < /etc/fail2ban/blocklists/blocked_ips.txt

actionstop  = iptables -D INPUT -j f2b-antiproxies
              iptables -F f2b-antiproxies
              iptables -X f2b-antiproxies

actionban   = iptables -I f2b-antiproxies -s <ip> -j DROP

actionunban = iptables -D f2b-antiproxies -s <ip> -j DROP

Frequently asked questions

What is the difference between Fail2ban and ipset for this use case?
ipset + iptables is more efficient for large static lists. Fail2ban is better if you also want to combine reactive banning (from log events) with proactive blocking from a static list in one tool.
Does bantime = -1 mean permanent ban?
Yes. A bantime of -1 means the IP is never automatically unbanned. Use fail2ban-client set antiproxies unbanip <IP> to manually remove one.

Put the full dataset in your stack

€99/year gets you all 22 data categories, unlimited local queries, and one year of updates. Load the files once, keep your decision logic in-house, and update on your own deployment schedule.

30-day money-back guarantee
All databases included
Monthly updates