Lockout warning:
A firewall change can lock you out of your own server. Before you turn off test mode, allow your own IP address and your SSH port, and keep an existing SSH session open until a new login works.
sh install.sh, and check the Perl modules with csftest.pl. Allow your own IP address with csf -a, check the open ports in TCP_IN, then set TESTING = "0" and restart with csf -r. On cPanel servers, manage it in WHM under Plugins > ConfigServer Security & Firewall.What CSF does
CSF (ConfigServer Security & Firewall) is a firewall front end for iptables, with a login failure daemon called lfd. Together they:
- Open only the ports you list, and block everything else.
- Block IP addresses that fail too many logins to SSH, cPanel, email or FTP.
- Alert you by email about suspicious logins, processes and file changes.
- Block whole countries, if you choose to.
- Add a WHM plugin for managing the firewall from the browser.
Before you install
- ✓ Root access to a VPS or dedicated server running AlmaLinux, Rocky Linux, CloudLinux, Debian or Ubuntu.
- ✓ Console access (VNC or KVM) in case a rule blocks SSH.
- ✓ Your own public IP address. Search “what is my IP” from your computer.
- ✓ Only one firewall manager. Turn off firewalld or ufw before you start CSF.
Step 1: install the dependencies
# AlmaLinux, Rocky Linux, CloudLinux
dnf install -y wget tar perl perl-libwww-perl perl-LWP-Protocol-https perl-GDGraph ipset
systemctl disable --now firewalld 2>/dev/null
# Debian and Ubuntu
apt install -y wget tar perl libwww-perl liblwp-protocol-https-perl libgd-graph-perl iptables ipset
ufw disable 2>/dev/null
Step 2: download and install CSF
cd /usr/src
wget https://backup.underhost.com/mirror/configserver/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
# Check that the required Perl modules and iptables features are present
perl /usr/local/csf/bin/csftest.pl
csftest.pl should end with “RESULT: csf should function on this server”. CSF installs in test mode, where its rules are cleared automatically every few minutes, so a mistake cannot lock you out for long.
Already running an older CSF? The mirror also has a migration script that backs up your settings, installs v15.00 and restores them. Try it first with --dry-run. See the mirror page for the commands.
Step 3: allow your own IP address
csf -a YOUR.PUBLIC.IP.ADDRESS "my office"
Addresses in the allow list are never blocked by lfd. Add every fixed IP address you or your team use.
Step 4: check the open ports
Open /etc/csf/csf.conf, or WHM’s Firewall Configuration page, and review these settings:
| Setting | What it controls |
|---|---|
| TCP_IN | Incoming TCP ports. Must include your SSH port, web (80, 443), mail and cPanel ports you use. |
| TCP_OUT | Outgoing TCP ports the server may connect to. |
| UDP_IN / UDP_OUT | UDP ports, for example DNS (53). |
| LF_ALERT_TO | Email address for alerts. |
| LF_SSHD, LF_CPANEL, LF_SMTPAUTH | Number of failed logins before an IP address is blocked. |
| CC_DENY / CC_ALLOW | Country blocking and allowing. |
If you moved SSH to another port, make sure that port is in TCP_IN, and remove 22 only after you have tested the new port.
Step 5: turn off test mode
- Set
TESTING = "0"in csf.conf, or untick Testing in WHM, and save. - Restart CSF and lfd with
csf -ra. - Open a new SSH session and log in. Keep the old session open until this works.
Everyday commands
| Command | What it does |
|---|---|
csf -a IP / csf -ar IP |
Allow an IP address / remove it from the allow list |
csf -d IP / csf -dr IP |
Block an IP address / remove the block |
csf -td IP 3600 |
Block an IP address for one hour |
csf -g IP |
Show every rule that mentions an IP address |
csf -t |
List temporary blocks and allows |
csf -r |
Restart the firewall after changes |
csf -x / csf -e |
Turn the firewall off / on |
csf -v |
Show the installed version |
If you lock yourself out
- Log in through your provider’s console.
- Run
csf -g YOUR.IPto see why you are blocked. - Remove the block with
csf -dr YOUR.IPand add yourself withcsf -a YOUR.IP. - If nothing else works, run
csf -xto turn the firewall off, fix the setting, thencsf -e.
Good practice
- ✓ Use SSH keys and turn off SSH password logins. CSF limits guessing, keys stop it.
- ✓ Keep the allow list short and up to date.
- ✓ Read the lfd alert emails, and act on repeated login failures.
- ✓ If you use Cloudflare, add Cloudflare’s IP ranges to the allow list so visitors are never blocked through it.
- ✓ Add a malware scanner such as Linux Malware Detect.
Need help with this?
Want your firewall set up and watched by experts? Our server management team configures CSF and responds to alerts.
Frequently asked questions
Is CSF still available after ConfigServer closed?
Yes. CSF was released under the GPLv3 as version 15.00. UnderHost keeps a mirror of the release and the other ConfigServer tools.
Does CSF work on Ubuntu and Debian?
Yes. Install the Perl dependencies, turn off ufw, and run csftest.pl to check the server.
How do I unblock an IP address in CSF?
Run csf -dr IP for a permanent block, or check csf -t for temporary blocks and remove them with csf -tr IP.
Can I run CSF together with firewalld or ufw?
No. Use one firewall manager. Turn off firewalld or ufw before you enable CSF.
Where are the CSF settings?
In /etc/csf/csf.conf, and on cPanel servers in WHM under Plugins > ConfigServer Security & Firewall.
Related guides
- How to Configure ModSecurity in cPanel for Advanced Security
- Updated MARCH 2025: How to Install and Configure ClamAV Antivirus on a VPS or Dedicated Server
- How to Install Linux Malware Detect (LMD)
- Top cPanel Security Tips to Keep Your Hosting Environment Safe
- Node.js Security Update (October 2026): CVE-2026-111497
