selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

GitHub
nftables blacklist logo

Self-host nftables blacklist

Bash script to block malicious IPs via nftables blacklists

ReleaseOpen SourceMIT
Updatedlast month
LanguageShell
Setup difficultyModerate
Stars
37
Requires
Iprange, Nftables
Install with Linux

What is nftables blacklist?

This bash script fetches IP addresses from public blocklists and applies them as nftables rules on Linux servers. It handles both IPv4 and IPv6 with CIDR notation, merges overlapping ranges automatically, and performs atomic rule swaps. The tool can process over 100,000 blocked IPs and includes automatic whitelisting of the server's own addresses. It runs on any Linux system with nftables and the iprange utility, and can be executed manually, scheduled via cron, or managed through systemd services and timers. All configuration lives in a bash config file where users define blocklist sources, whitelist entries, and runtime options.

nftables blacklist alternatives

Should you self-host nftables blacklist?

nftables blacklist scores 42/100 on selfhost.directory (how scoring works) and ranks #8 of 15 in Network Security. It has 37 GitHub stars, +15 in the last 30 days.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is moderate: expect some configuration beyond a single command. It is MIT-licensed and written mostly in Shell.

Its closest alternative on selfhost.directory is bettercap (76/100, 20 279 stars). It scores higher overall, so compare the two before you pick. See nftables blacklist vs bettercap side by side.

Features

  • Atomic updates
  • Auto-whitelisting
  • CIDR aggregation
  • Country/ASN blocking
  • Cron/systemd timer support
  • Custom blacklist sources
  • Drop packet counters
  • Dry Run Mode
  • External whitelist files
  • Forward chain blocking
  • IPv4 and IPv6 blocking
  • Large IP set handling
  • Persistence across reboots

nftables blacklist README

nftables-blacklist (formerly ipset-blacklist)

CI Bash 4.0+ License

⭐ This repo survived thirteen years and a spell in the Arctic Code Vault, then a coding agent I was running flipped it private for about two minutes. GitHub responded by vaporising all 766 stars and cutting all 181 forks loose. The code is fine. My pride is not.

If you forked before 25 August 2026: your copy still works, it is just no longer linked here. Re-fork if you want GitHub's "Sync fork" button back.

If you had starred it: yours is gone too. A re-star is appreciated, but the script works either way.

How to install nftables blacklist

Install nftables blacklist with Linux

nftables, iprange, curl, grep, sed, sort, wc

sudo apt install curl iprange sudo curl -fsSL -o /usr/local/sbin/update-blacklist.sh https://raw.githubusercontent.com/trick77/nftables-blacklist/master/update-blacklist.sh sudo chmod +x /usr/local/sbin/update-blacklist.sh sudo mkdir -p /etc/nftables-blacklist sudo curl -fsSL -o /etc/nftables-blacklist/nftables-blacklist.conf https://raw.githubusercontent.com/trick77/nftables-blacklist/master/nftables-blacklist.conf sudo /usr/local/sbin/update-blacklist.sh /etc/nftables-blacklist/nftables-blacklist.conf

Debian 10+ / Ubuntu 20.04+ or any Linux with nftables

How to configure nftables blacklist

  • ENABLE_IPV4yesBlock IPv4 addresses
  • ENABLE_IPV6yesBlock IPv6 addresses
  • FORCEnoAutomatically create the nftables table/sets if they don't exist. The shipped config sets `yes`; if you omit the setting entirely the script aborts instead of creating the table
  • AUTO_WHITELISTnoAuto-detect and whitelist your server's own IPs (setting this to `yes` is recommended)
  • BLOCK_FORWARDnoAlso block blacklisted IPs in the forward chain — forwarded traffic (e.g. to containers) is NOT blocked unless set to `yes`

More in Network Security

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…