Skip to content

CSF and LFD rules that actually pay off on a cPanel host

The CSF and LFD settings worth tuning beyond the defaults — port knocking, country denies, process tracking, and the limits that prevent false alerts.

The CSF default config gets you 80% of the value. The remaining 20% is in a handful of settings most operators ignore until they have a postmortem to write. This is the short list of CSF and LFD rules that we keep adjusting on cPanel hosts in production.

What’s happening

CSF and LFD together cover three concerns: who can reach the host (firewall), who is allowed to fail logging in (LFD watchers), and which processes are misbehaving (process and account tracking). The defaults are conservative — useful as a starting point, but not what we run in production.

How to verify

csf -l | wc -l
grep -E "^(LF_|PT_|CC_|CT_) " /etc/csf/csf.conf | grep -vE "= \"\"$|= 0$" | head -30
csf -ta
csf -td
tail /var/log/lfd.log

csf -ta shows temporary allows, csf -td shows temporary denies. The grep narrows csf.conf down to non-default values.

The fix

  1. PT_LIMIT = 60 — process-tracking on. LFD will alert on long-running suspicious processes, which is how mass-mailer scripts usually surface.
  2. PT_USERPROC = 10 — alert when a user has more than 10 long-running processes. Tune up for actual high-tenant hosts.
  3. CT_LIMIT = 300, CT_INTERVAL = 30 — connection tracking. Catches both DDoS and runaway scrapers.
  4. CC_DENY — only if you have a clear traffic profile. Adding CN,RU,KP reflexively is lazy and breaks legitimate users; pick the list deliberately and review quarterly.
  5. LF_DISTATTACK = 1 with LF_DISTATTACK_UNIQ = 2 — catches distributed brute force where one IP only tries twice.
  6. LF_SCRIPT_ALERT = 1 — emails when a script is sending more than LF_SCRIPT_LIMIT (default 100/h) messages. This is the single best early-warning for compromised tenants on cPanel.
  7. DYNDNS = 300 — refresh dynamic-DNS entries in csf.dyndns every 5 minutes so home-office IPs that change do not get the operator locked out.

Stack Harbor maintains CSF tuning files in a central repo and re-applies them on takeover as part of managed cPanel operations.