Useful CSF SSH Command Line Commands (CSF Cheat Sheet)

This article covers some useful ConfigServer Firewall (CSF) SSH command line commands in a "cheat sheet" format.

csf -eEnable CSFroot@server[~]#csf -e
csf -xDisable CSFroot@server[~]#csf -x
csf -sStart the firewall rulesroot@server[~]#csf -s
csf -fFlush/Stop firewall rules (note: lfd may restart csf)
root@server[~]#csf -f
csf -rRestart the firewall rulesroot@server[~]#csf -r
csf -a [] [Optional comment]Allow an IP and add to /etc/csf/csf.allow
root@server[~]#csf -a Home IP Address
csf -td [] [Optional comment]Place an IP on the temporary deny list in /var/lib/csf/csf.tempbanroot@server[~]#csf -td Odd traffic patterns
csf -tr []Remove an IP from the temporary IP ban or allow list.
root@server[~]#csf -tr
csf -tfFlush all IPs from the temporary IP entries
root@server[~]#csf -tf
csf -d [] [Optional comment]Deny an IP and add to /etc/csf/csf.denyroot@server[~]#csf -d Blocked This Guy
csf -dr []Unblock an IP and remove from /etc/csf/csf.denyroot@server[~]#csf -dr
csf -dfRemove and unblock all entries in /etc/csf/csf.denyroot@server[~]#csf -df
csf -g []Search the iptables and ip6tables rules for a match (e.g. IP, CIDR, Port Number)root@server[~]#csf -g
csf -t Displays the current list of temporary allow and deny IP entries with their TTL and comments root@server[~]#csf -t

Whitelisting an IP Address

In order to prevent specific IP from being blocked, even for a temporary deny, you need to list their IP address in the files csf.ignore and csf.allow. The first step is to enable IGNORE_ALLOW in csf.conf. The value for IGNORE_ALLOW will appear as "0", you will need to adjust it to "1" and restart csf and lfd.

This will allow lfd to reference csf.ignore. If you add an IP address to csf.ignore, the IP address will no longer be checked by lfd and failed login attempts will not trigger temporary denies.