ipfence home page local-first intrusion prevention for Linux

A doorman for your Linux server

Any server on the internet is constantly poked by automated programs. They guess SSH passwords thousands of times, and ask web servers for files that should never be public. ipfence notices this in the server's own logs and tells the Linux firewall to ignore that visitor for a while.

It’s an early, open-source project, and it only watches until you switch blocking on.

Five wrong passwords later

Someone at 203.0.113.50 is guessing the root password, and the SSH server writes each try down:

sshd-session[1110]: Failed password for root from 203.0.113.50 port 53585 ssh2

After the fifth within ten minutes, ipfence logs its decision:

level=INFO msg=decision event=ban address=203.0.113.50 service=ssh reason="5 SSH authentication failures within 10m (latest: failed-password)"

It puts the address in a firewall table of its own:

elements = { 203.0.113.50 timeout 14m59s992ms expires 14m57s268ms }

And the next attempt gets nothing back:

ssh: connect to host 203.0.113.1 port 22: Connection timed out

Another visitor in the same test got through as usual. The ban lifts after 15 minutes; repeat offenders get 6 hours, then 7 days. Follow the whole attack.

From a test run in a virtual machine, with blocking switched on. Addresses starting 203.0.113. are reserved for examples.

Running it

Watch first, then block

It starts in observe mode: it records what it would ban and changes no firewall rule until you run ipfence enable.

Nginx and Caddy detection stays off until you turn it on and say how visitors reach you. Stopping the program leaves the firewall rules in place.

Build and try it

Use a machine you can still reach another way, such as your provider’s console.

Needs Go 1.27.4 or newer.

Shell commands

git clone https://github.com/nothikemu/ipfence.git
cd ipfence
scripts/build.sh
sudo install -m 0755 dist/ipfence-linux-amd64 /usr/local/bin/ipfence
sudo install -m 0644 systemd/ipfence.service /etc/systemd/system/ipfence.service
sudo systemctl daemon-reload

Then, in order: see what it can protect, start it watching, read what it would ban, and only then start blocking.

Shell commands

sudo ipfence init
sudo systemctl enable --now ipfence
sudo ipfence status
sudo ipfence enable

init never changes the firewall. If you run it from an SSH session it allowlists that session's exact client address and says so.

Getting started explains each step. After that: everyday tasks.

Locked out? sudo ipfence disable --yes removes every ipfence rule, and there are other ways back in.

What stays on your machine

ipfence's built-in components never send anything off your machine. No telemetry, crash reports, update checks, accounts, API keys, shared threat feeds, downloaded databases or remote parsers. Rules, history and logs stay local.

One thing you can add does send data wherever you choose: the optional hook, a program of yours that runs after a ban. It is off unless you configure it, and the unit's network block applies to it until you remove that block.

Privacy and threat model

What it won’t do

  • It is not a web application firewall and does not protect against volumetric denial of service.
  • It cannot block a visitor who reaches you through a reverse proxy or CDN: this host only ever sees the proxy's address.
  • It does not treat a bare 401 or 403 as a failed login, and has no generic "suspicious URL" rules.
  • It does not read container logs or detect services running inside containers.
  • It cannot promise you will never be locked out. It exempts what it can verify and gives you ways back in; see IPv6 and lockout.

This is an early release. It has automated tests and an adversarial review by its author; it has not had an independent security audit.

Tested on

Tested (amd64 virtual machines) Kernel systemd OpenSSH Nginx Caddy
Debian 13 6.12 257 10.0p2 1.26 2.6
Debian 12 6.1 252 9.2p1 1.22 2.6
Rocky Linux 9.9, SELinux enforcing 5.14 252 9.9p1 1.20 2.6

Results from 28 November 2026, in virtual machines, with arm64 under emulation only. It has not been tried on physical hardware or on other distributions. How it was tested.