Design decisions
Why ipfence is the way it is. "Brief" means the requirement came from the original project brief; "choice" means it was decided while building and is yours to revisit.
Foundations
| Decision | Why | Cost | Origin |
|---|---|---|---|
| Go, no C code | one static binary that runs on any distribution | SQLite and netlink through Go libraries | brief |
| nftables through netlink | no shelling out to nft; atomic batches |
depends on an early-stage library | brief |
journal through journalctl |
no C library; works with standard systems | needs the program present | brief |
| SQLite | durable, transactional, single file | one writer | brief |
| MIT license | the repository had none; short and compatible with the libraries | choice within the brief | |
| local only | the point of the project | no shared threat lists | brief |
Behaviour
| Decision | Why | Alternative | Origin |
|---|---|---|---|
observe by default; enable is explicit |
judge it before trusting it | block immediately | brief (commands added by choice) |
| deny-only rules, one table | cannot open anything; cannot damage others' rules | accept rules for allowlisted sources | brief |
| allowlist inside every rule | holds even inside network bans | early accept rule | choice |
| private addresses not auto-banned | most likely you | ban them | choice |
| carrier-grade NAT bannable | blanket allowing it exempts strangers | allow it | brief |
| ban ladder 15 m, 6 h, 7 d | short first mistake, long repeat | one fixed length | brief |
| thresholds: SSH 5 in 10 m, web probes 3 in 10 m | common conservative values | choice | |
| public-key failures ignored | legitimate multi-key users | count them | choice |
| web detection is probes only | 401 and 403 are normal | count error codes | brief |
| file probes only on 4xx | a real file is not penalized | count all | choice |
| nginx error log not read | free text containing client input is hard to parse safely | parse basic-auth failures | choice |
web detectors need clients declared |
only the owner knows whether a CDN is in front | assume direct | choice |
manual bans limited to /8 and /32 |
typo protection | no limit | choice |
ban refused while disabled |
never pretend to block | record silently | choice |
unban keeps history |
repeat offenders still escalate | forget | choice; --reset-history |
| stop never removes rules | restarting must not remove protection | clean up on stop | brief |
| foreign content makes the table read-only | never delete what you did not write | overwrite | brief |
docker.mode = "forward" is opt-in |
affects all forwarded traffic | on automatically | choice |
A judgment call to revisit
The brief says experimental or untested container modes should stay disabled.
ipfence ships docker.mode = "forward" off, tested on Docker 26.1 and 29.10.
It can be enabled on Docker 29's native nftables backend, which Docker itself calls
experimental; status says so. If you want it refused there instead, that is a small
change in discovery and the firewall options.
Engineering
| Decision | Why |
|---|---|
| database before firewall | a crash leaves a record that reconciliation applies |
| always send the complete desired state | one code path, self-repairing |
| events and reader position in one transaction | counted exactly once |
| one writer: daemon socket, or lock | no races between commands and the daemon |
| readers wait for the database | nothing dropped under load |
| ownership logic separate from netlink code | testable without a kernel |
Bugs found by testing
| Found by | Problem | Fix |
|---|---|---|
| kernel test | network bans failed on the real kernel | no timeout on interval end markers |
| kernel test | removing thousands of bans failed | larger netlink buffers |
| end-to-end on ufw | ufw enabled from its own command was not reported | read ufw.conf |
| inspecting Rocky Linux | its default Nginx format was unreadable | main preset and a hint |
| code review | realip added after start could ban header-derived addresses |
recheck every minute; stop the reader and forget its position |
| code review | log formats without escaping allow forged lines | refuse them |
| code review | status could show a ban as enforced after the table was removed | check the table first |
| sample output | parser shown as unverified while parsing; Docker note ignored forward mode | corrected |
| end-to-end on Rocky | restart limit too low for editing settings | raised to 20 |
| unprivileged check | init called an unreadable config "invalid" |
report permission |
| checklist review | status did not say Docker's nftables backend is experimental | added |
Most were reproduced by a failing test or check before they were fixed, including the three code review findings. Two were not: the wording of the Docker note for an unreachable engine was changed together with its test, and the restart limit was a setting adjusted and then verified by rerunning the scripts.
Known rough edges
Cosmetic or minor behaviours seen in testing and not yet fixed:
| Behaviour | Why it is confusing |
|---|---|
ban 0.0.0.0/0 suggests --force |
the range also contains your SSH client, so that guard answers first; with --force it is then refused for being too wide |
ban 10.0.2.2 (your own client) says "10.0.2.2 includes 10.0.2.2" |
awkward wording |
ban while the table is foreign prints "banned ..." before "NOT enforced" |
the first line reads as success; exit code 5 and the second line are correct |
test on a successful-login line says "no supported parser recognizes this line" |
it is recognized as SSH but is not a failure |
test needs sudo once init has created the settings file |
it changes nothing, but the file is readable by root only |
Known limitations
| Limitation | Detail |
|---|---|
| web login failures not detected | probes only |
| visitors behind proxies cannot be blocked | the firewall sees the proxy |
| container logs and in-container services not supported | |
| distributed and IPv6-rotating attackers can stay under thresholds | |
copytruncate rotation loses lines |
unavoidable |
| settings changes need a restart | no reload |
| realip changes noticed within about a minute | |
| no geolocation lookup | optional in the brief, not built |
| tested only on virtual machines | no hardware testing; no Ubuntu, Fedora, Alpine or Arch |
| no independent security audit | |
| name not cleared | see Release procedure |
Ideas, not promises
Failed-login rules for declared endpoints; reading Docker logs for supported drivers; configuration reload; a continuous-integration workflow; packages for distributions. None of these exists today.