Open source · Go · IPv4 · CLI
flokbn is a Go CLI that clusters the IPs in your access logs into CIDR ranges. A binary trie does the heavy lifting - a 2-million-line log takes about a second on an ordinary workstation. Use it for botnet detection, abuse analysis, or building ban lists.
Measured on a 2.3M-request real-world dataset on a single Linux workstation - your numbers will vary with hardware and log shape. Full benchmarks →
00 / SEE IT RUN
Point flokbn static at an access log and give it one or more cluster arg sets - minSize,minDepth,maxDepth,threshold. Each set is a detection tier: tight ones catch single hot hosts, loose ones catch whole subnets misbehaving together.
iptables, nftables, or a WAF$ flokbn static --logfile /var/log/nginx/access.log \
--clusterArgSets 1000,24,32,0.1 \
--clusterArgSets 10000,16,24,0.2 --plain
ANALYSIS OVERVIEW
────────────────────────────────────────────
Total Requests: 2,345,057
Parse Rate: 4,388,769 requests/sec
Duration: 570 ms
CLUSTERING RESULTS (2 sets)
────────────────────────────────────────────
Set 1: min_size=1000, depth=24-32, threshold=0.10
192.0.2.86/32 1,574 requests ( 0.07%)
198.51.100.192/26 3,083 requests ( 0.13%)
Set 2: min_size=10000, depth=16-24, threshold=0.20
203.0.113.0/24 52,868 requests ( 2.25%)
198.51.100.0/24 28,812 requests ( 1.23%)01 / HOW IT WORKS
Configurable format strings read Apache, Nginx, or custom logs. An IP-only fast path skips every field the analysis doesn’t need.
Log formatsTime windows, whitelist/blacklist files, and regex filters on User-Agent and endpoint - with a literal prefilter so the regex engine rarely runs.
FilteringEvery surviving IP is inserted into a binary trie - on the reference dataset, clustering then runs in microseconds per arg set.
InternalsConfigurable depth ranges and thresholds walk the trie and emit the CIDR ranges where traffic concentrates.
ClusteringDetected ranges land in a persistent jail - the state your firewall automation reads to ban and unban.
Jail system02 / TWO MODES
Analyze historical log files. Slice by time window, query specific CIDR ranges, and - when the use case calls for it - generate a ban-candidate list from what actually happened.
Continuous monitoring over the Lumberjack protocol (Filebeat-compatible). Sliding windows watch traffic in real time; detected ranges are banned automatically.
slidingWindowMaxSize/stats, /bans and Prometheus /metrics endpoints03 / FEATURES
IPs group into CIDR ranges without manual configuration - you tune size, depth, and threshold, the trie does the rest.
Run several detection configurations simultaneously in one pass - one log read, many perspectives.
Whitelist and blacklist files, regex on User-Agent and endpoint, and time-based windows - combined freely.
Inspired by fail2ban: the output is a list of CIDR ranges with request counts - a ready-made candidate list for bans or rate limits.
JSON for pipelines, compact JSON for storage, plain text for humans, and an interactive TUI for exploration.
Zero-copy chunked I/O, an IP-only parse path, regex literal prefiltering, memory pools - the performance work is documented and benchmarked.
04 / THE DOCS
Learn how to install and use flokbn for IP clustering and blacklist generation
02Walkthrough guides for static analysis, live protection, the Docker test and demo stacks, and IP clustering
03Authoritative reference for CLI flags, TOML configuration, log formats, clustering, filtering, and output formats
04Deep dive into flokbn internals, performance optimization, and scaling
05Get started contributing to the flokbn open-source project
%h field per log format. Multiple IP fields are not supported.