Log inSign up

Set up CSF and the login failure daemon on a VPS

CSF is a Perl front end for iptables plus a companion daemon (LFD) that bans IPs after failed logins. Install the Perl and iptables dependencies, unpack the CSF release, run sudo sh install.sh, check the kernel with csftest.pl, set your ports in /etc/csf/csf.conf while TESTING = "1", then switch testing off and run sudo csf -ra. Because the original developer no longer maintains CSF, get the code from a community repository you trust and consider UFW or firewalld for new servers.

Topic: Security · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

What is the maintenance status of CSF?

The original company behind ConfigServer Security and Firewall stopped developing it and published the source under an open source license. Since then, community volunteers have kept forks alive with fixes for newer distributions, and the old official download address may no longer serve files. That has two consequences. First, pick a fork whose recent activity, issue tracker and release notes you can review, and verify checksums or signatures if the project publishes them. Second, think about whether you need CSF at all: on a fresh server, UFW or firewalld plus fail2ban cover the same ground with packages your distribution patches for you.

CSF still makes sense when you already run it across many servers, when a control panel integrates with it, or when your team knows its configuration files well.

What does CSF add over a plain firewall?

CSF bundles several jobs in one package. The firewall part turns simple port lists in csf.conf into iptables rules for IPv4 and IPv6. LFD, the login failure daemon, watches logs for repeated failed logins on SSH, mail, FTP and web panels, then blocks the source with a temporary or permanent ban. It can also alert on suspicious processes, changed system files and new user accounts. Everything is driven by plain text files under /etc/csf/, which suits people who manage servers by editing config rather than typing rule commands.

How do I prepare the server?

Run only one firewall manager. Disable the one your image ships before installing CSF, and make sure your SSH key login works (see SSH keys and hardening). On Ubuntu and Debian:

sudo ufw disable
sudo apt update
sudo apt install perl libwww-perl liblwp-protocol-https-perl libgd-graph-perl iptables ipset tar wget

On Rocky Linux 9 and AlmaLinux 9:

sudo systemctl disable --now firewalld
sudo dnf install perl perl-libwww-perl perl-LWP-Protocol-https iptables-nft ipset tar wget

The GD graph module is optional and only used for the statistics graphs. If a later step complains about a missing Perl module, install it with the package manager rather than CPAN so security updates keep reaching it.

How do I install CSF?

Download the release archive from the community repository you chose into a temporary folder, check it, unpack it and run the installer as root:

cd /tmp
# fetch csf.tgz from the maintained repository, then:
sha256sum csf.tgz
tar -xzf csf.tgz
cd csf
sudo sh install.sh

Then confirm that the kernel offers the iptables features CSF needs:

sudo perl /usr/local/csf/bin/csftest.pl

The last line should read that CSF should function on this server. A KVM VPS like ours has a full kernel, so the test normally passes. Check the version with sudo csf -v.

How do I open ports and leave testing mode?

Edit the main configuration and set the port lists before you turn the firewall on for real. CSF starts in testing mode, where a cron job flushes the rules every few minutes, so a mistake cannot lock you out permanently:

sudo nano /etc/csf/csf.conf

Look for these settings and adjust them to your services. Keep your SSH port in every TCP list:

TESTING = "1"
TCP_IN = "22,80,443"
TCP_OUT = "20,21,22,25,53,80,443,587,853"
UDP_IN = ""
UDP_OUT = "53,123"
TCP6_IN = "22,80,443"
TCP6_OUT = "20,21,22,25,53,80,443,587,853"

Apply and test with a second SSH login from your computer:

sudo csf -ra
ssh deploy@198.51.100.24

When the new login works and your sites respond, set TESTING = "0", run sudo csf -ra again and enable both services at boot with sudo systemctl enable csf lfd.

How do I allow, block and look up IP addresses?

Use the command line flags, which also write to the matching files in /etc/csf/:

sudo csf -a 203.0.113.50 "office"
sudo csf -d 192.0.2.77 "abuse"
sudo csf -td 192.0.2.78 3600 "one hour ban"
sudo csf -g 192.0.2.77
sudo csf -dr 192.0.2.77
sudo csf -tf

The -a flag allows an address, -d denies it permanently, -td denies it for a number of seconds, -g searches all rules, -dr removes a permanent deny and -tf flushes temporary bans. Addresses listed in csf.ignore are never banned by LFD, which is where your own static IP belongs.

How do I tune the login failure daemon?

LFD settings live in the same csf.conf. The LF_SSHD value sets how many failed SSH logins trigger a block, LF_SSHD_PERM decides whether the block is permanent or temporary, and LF_TRIGGER switches to a global counter across services. Watch the daemon at work:

sudo tail -f /var/log/lfd.log
sudo systemctl status lfd

LFD sends alerts by email to the address in LF_ALERT_TO. Outgoing mail on port 25 is not guaranteed on a VPS, so ask support by ticket before relying on direct delivery, or point the server at an authenticated relay on port 587.

How do I troubleshoot or remove CSF?

If you are locked out, wait: in testing mode the rules clear themselves within minutes. Outside testing mode there is no browser console on our servers, so a full lockout means a reinstall from the Settings tab, which erases the disk. That is why the second login test matters. To inspect what CSF loaded, run sudo csf -l, and after Docker or other tools add rules, restart CSF so its chains come first. If CSF fights with another firewall, check that UFW and firewalld are both inactive.

To remove CSF completely, run the bundled script and then enable your replacement firewall:

sudo sh /etc/csf/uninstall.sh

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-1CSF and LFD need only a few dozen MB of memory1 vCPU, 1 GB RAM, 25 GB NVMe$3.60/mo$43.20 for 12 months

Questions about CSF firewall (ConfigServer Security)

Is CSF still safe to use?

The code works on current systems through community forks, but it no longer has its original maintainer. Review the fork you install and keep an eye on its updates, or prefer distribution packaged tools for new servers.

Can I run CSF together with UFW or firewalld?

No. Each one rewrites the packet filter rules, so running two leads to confusing results. Disable the others before installing CSF.

Does CSF protect IPv6?

Yes when IPv6 is enabled in csf.conf. Fill the TCP6_IN and TCP6_OUT lists too, otherwise your IPv6 address may expose different ports than IPv4.

Does CSF work with Docker?

It can, but Docker writes its own rules. Restart CSF after Docker starts, or check the Docker related options in csf.conf provided by your fork.

What is a good alternative to LFD?

Fail2ban and CrowdSec both watch logs and ban abusive addresses, and both are packaged for Ubuntu, Debian and the RHEL family.