Security

Allow, deny and temporarily ban IP addresses in CSF

Use CSF commands and the WHM interface to whitelist trusted IPs, permanently deny attackers, add temporary bans and ignore IPs in LFD, with the files behind each list.

IntermediateWHM (root)2 min read

CSF keeps several lists of IP addresses: ones that are always allowed, ones that are always denied, short temporary bans, and IPs that LFD should never block. Knowing which list to use keeps trusted users connected while attackers stay out.

Before you start

  • Root access to a server running CSF. If it is not installed yet, follow install and configure CSF on WHM.
  • The IP or range you want to manage. CIDR ranges such as 198.51.100.0/24 are accepted.

The four lists

ListFileEffect
Allow/etc/csf/csf.allowAlways allowed through the firewall on all ports.
Deny/etc/csf/csf.denyAlways blocked until removed.
TemporaryMemory (/var/lib/csf/csf.tempban)Blocked or allowed for a set time, then removed automatically.
Ignore/etc/csf/csf.ignoreLFD will never block it, but normal port rules still apply.

Allow (whitelist) an IP

  1. From SSH:
    csf -a 203.0.113.10 "office static IP"
  2. Or in WHM → Plugins → ConfigServer Security & Firewall, type the IP in Quick Allow, add a comment and click Quick Allow.

Warning: An allowed IP bypasses every port rule and every LFD block. Only allow static IPs you control. For a home IP that changes, prefer the ignore list or a port-specific rule.

Allow one port only

Add an advanced rule to csf.allow to let an IP reach just one service, for example SSH:

tcp|in|d=22|s=203.0.113.10

Then reload with csf -r.

Deny (blacklist) an IP

csf -d 198.51.100.7 "wp-login brute force"

In WHM use Quick Deny. Remove a deny with csf -dr 198.51.100.7. Keep the deny list tidy; DENY_IP_LIMIT in csf.conf caps how many entries are kept.

Temporary bans and allows

  1. Ban an IP for one hour (time in seconds):
    csf -td 198.51.100.7 3600 "testing ban"
  2. Ban only on one port, for example 443:
    csf -td 198.51.100.7 3600 -p 443
  3. Allow a contractor for one day:
    csf -ta 203.0.113.50 86400 "contractor"
  4. List and remove temporary entries:
    csf -t
    csf -tr 198.51.100.7

In WHM these are under Quick Actions → Temporary Allow/Deny and View temporary IP entries.

Stop LFD blocking an IP (ignore)

Add the IP, one per line, to /etc/csf/csf.ignore (WHM: Firewall Allow IPs → csf.ignore), then restart LFD:

systemctl restart lfd

This suits monitoring services or an office whose staff mistype passwords often.

Check afterwards

  • Search every list for an IP: csf -g 198.51.100.7.
  • Ask the user to reconnect; if they still fail, the block may come from cPHulk, Imunify360 or ModSecurity instead. See why is my IP blocked.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.