ipfence home page local-first intrusion prevention for Linux

Manual pages

Troubleshooting

Symptoms, how to find the cause, and how to fix it. For what a particular message means see Messages and errors.

Start here

Three commands answer most questions. None of them changes anything.

Shell commands

sudo ipfence status                      # what ipfence thinks
sudo journalctl -u ipfence -n 50         # what the daemon said
sudo nft list table inet ipfence         # what the kernel holds (needs the nft tool)
noyesnoyesnoyesnoyesnoyesSomething is wrongDaemon running?Service will not startEnforcement ENABLED?run: ipfence enableDetector active?A detector is not activeBan listed?An attacker is not being bannedIN FIREWALL yes?Firewall statesBanned traffic still arrives
Diagram source
flowchart TD
    A["Something is wrong"] --> B{"Daemon running?"}
    B -- no --> S["Service will not start"]
    B -- yes --> C{"Enforcement ENABLED?"}
    C -- no --> E["run: ipfence enable"]
    C -- yes --> D{"Detector active?"}
    D -- no --> DET["A detector is not active"]
    D -- yes --> F{"Ban listed?"}
    F -- no --> NB["An attacker is not being banned"]
    F -- yes --> G{"IN FIREWALL yes?"}
    G -- no --> FW["Firewall states"]
    G -- yes --> H["Banned traffic still arrives"]

Nothing is being blocked

Check Fix
Enforcement disabled sudo ipfence enable. Observed decisions are not turned into bans
Daemon not running sudo systemctl enable --now ipfence
detector disabled read its four links; "to activate" lists what is missing
ban listed but IN FIREWALL NO see Firewall states

A detector is not active

Look at its row in status. The first link that is not yes is the problem; the line under it says why.

Link Common causes Fix
DETECTED no the service is not installed or not running; it runs only in a container start it; containers are not supported
SOURCE no (ssh) the journal cannot be read run sudo journalctl -n 5; ipfence needs systemd's journal
SOURCE no (nginx, caddy) wrong log path; unreadable file set access_logs to the real path
SOURCE no (caddy) no log configured Caddy logs requests only if told to; add a log block, then set access_logs or journal_unit
PARSER no the log format does not match see format mismatch
PARSER unknown no line logged yet make one request; nothing else to do
PACKET PATH unknown clients not declared; firewall could not be read set clients; run status with sudo
PACKET PATH no Nginx rewrites visitor addresses (realip) see web servers
PACKET PATH no the firewall table is foreign or from another installation see Firewall states
all yes, still disabled not enabled in settings enabled = true for Nginx or Caddy

After changing settings: sudo systemctl restart ipfence.

An attacker is not being banned

You can see failures in the server's log, but no ban appears.

  1. Is it counted at all? Test one line exactly as logged:

    Shell commands

    sudo ipfence test "paste the line"

    "no supported parser" or "not a countable failure" means that kind of line is not one ipfence counts. See SSH and web probes.

  2. Is the address exempt or ignored? Look at "Local counters" in status:

    Counter rising Reason
    ignored.private_address a private address; see auto_ban_private
    ignored.allowlisted on your allowlist
    ignored.trusted_proxy, ignored.behind_proxy it arrives through your proxy
    ignored.local_address, ignored.loopback this machine itself
    ignored.stale events older than the window; check the server clock and time zone in logs
    ignored.future the clock or log timestamps are ahead
    ignored.already_banned it is already banned
    journal.untrusted the line did not come from a verified sshd
    file.unparsed the configured format is wrong
  3. Below the threshold? SSH needs 5 failures in 10 minutes from one address; web probes need 3. Attackers who spread attempts out, or use many addresses, can stay under it. You can lower threshold or lengthen window.

  4. Public key attempts? Rejected SSH keys are deliberately not counted.

journal.untrusted keeps rising

Either someone is writing fake sshd lines to your journal, or your sshd is installed somewhere unusual. Compare a real entry with the trust rules:

Shell commands

sudo journalctl -u ssh -n 1 -o json-pretty      # sshd on RHEL-family systems

Look at _COMM, _UID, _EXE and _SYSTEMD_UNIT. A non-standard unit name can be added with [ssh] units.

Banned traffic still arrives

Check Explanation
kernel counters in status rise when it connects it is being dropped; what you see is probably logged by something that captures packets earlier
the traffic goes to a container published ports need docker.mode = "forward"; see Firewall and Docker
the visitor comes through a CDN or proxy this server only sees the proxy; block there
the connection was open before the ban it is dropped too, but the client may take a while to notice
it uses another address (often IPv6) each address is banned separately

Confirm from the kernel while the banned machine connects:

Shell commands

sudo nft list table inet ipfence | grep -A1 counter

Someone legitimate is banned

Shell commands

sudo ipfence status                          # find the ban and its reason
sudo ipfence allow <address> --note "why"    # unban and never ban again

unban alone removes the ban but allows it to happen again. If the address is inside a banned range, allow exempts it while the range stays. If you are locked out yourself, see Everyday tasks.

Firewall states

State Meaning What to do
drifted ours but altered; repaired automatically if it recurs, find what is changing it
foreign the table holds something ipfence did not create inspect with sudo nft -a list table inet ipfence; remove the foreign object (sudo nft delete rule inet ipfence input handle N), or delete the table if you are sure it is not needed
other-install made by a different ipfence database (state was deleted or restored) sudo ipfence disable --yes && sudo ipfence enable, then sudo systemctl restart ipfence
unavailable nftables could not be read run as root; check the kernel has nf_tables
absent while enforcement is on something removed the table (for example nft flush ruleset) ipfence recreates it within about 15 seconds

The last happens if nftables.service is reloaded, because its configuration usually begins with flush ruleset.

While the table is foreign or other-install, a detector that starts up stays disabled, because a ban could not be applied. After fixing the table, restart the service so detectors notice at once; otherwise they return within about a minute.

Database problems

The daemon refuses to start, and leaves the file untouched, when the database is corrupt, newer than the program, or not an ipfence database.

  • Newer: install the newer ipfence again.

  • Corrupt or foreign: move it aside, keeping a copy, then start fresh:

    Shell commands

    sudo systemctl stop ipfence
    sudo mv /var/lib/ipfence /var/lib/ipfence.broken
    sudo ipfence disable --yes     # the old table belongs to the old identity
    sudo systemctl start ipfence
    sudo ipfence enable

    Bans and history in the old file are not carried over. Kernel entries with a timeout expire by themselves; permanent ones remain until the table is removed.

Service will not start

sudo journalctl -u ipfence -n 20 shows the reason.

Message Fix
start-limit-hit (systemd) sudo systemctl reset-failed ipfence && sudo systemctl start ipfence
config: unknown setting(s) fix the typo; the message names it
other config: messages see Messages
writable by group or others sudo chown root: /etc/ipfence/config.toml && sudo chmod 600 /etc/ipfence/config.toml
another ipfence process holds the writer lock a daemon or command is already running
No such file or directory for the program the binary is not at /usr/local/bin/ipfence
Exec format error wrong architecture binary
log under /home or /tmp not seen the service cannot see those; move the log or add a drop-in

To see an error directly in your terminal, with the service stopped:

Shell commands

sudo systemctl stop ipfence
sudo ipfence daemon          # Ctrl+C to stop

Command messages

  • recorded but NOT enforced: the decision is saved; the reason follows. ipfence retries every 15 seconds.
  • Exit 3: use sudo.
  • Exit 4: another writer is busy or the daemon is not answering; check systemctl status ipfence.
  • Exit 5: see Firewall states.
  • Exit 6: a safety refusal; the message says which.

Nginx detector reports a format mismatch

RHEL-family and nginx.org packages use the main format: set format = "main". For anything else, copy your log_format text into format and check it:

Shell commands

sudo ipfence test --service nginx "$(sudo tail -n1 /var/log/nginx/access.log)"

(Exit code 10 means the line was read but is not a probe.)

Events may have been missed

journal.cursor_lost, or a reader notice about rotation or truncation, means ipfence could not continue exactly where it stopped. It carries on from the best available point. This happens after the journal is trimmed (journalctl --vacuum-...), after log rotation while ipfence was stopped, or with copytruncate rotation. No action is needed unless it happens often.

The hook does not run

Check Fix
daemon not running hooks run only from the daemon, not from offline commands
msg="hook failed" in the journal the message says why
program writable by others, or not root-owned sudo chown root: PROGRAM && sudo chmod 755 PROGRAM
it needs to write a file add ReadWritePaths= in a drop-in
it needs the network blocked by the unit; see Installation
it relies on HOME or other variables only PATH is set

Reporting a bug

sudo ipfence status --json and ipfence version describe most problems. They contain IP addresses: remove anything you do not want to share. ipfence never sends them anywhere.