Docs

How to manage the CSF firewall and LFD from SSH

The everyday CSF and LFD commands on an intoPanel server: find why an address is blocked, allow and unblock addresses, open ports, temporary blocks, restart and read the logs.

How-to over SSH AlmaLinux, Rocky Linux, Ubuntu, Debian 2 min read Updated

intoPanel's installer sets up CSF as the server's firewall and LFD (Login Failure Daemon) as its login protection. Everything below can also be done in the admin area under Security → Firewall & Settings; the commands are for when you are already on the console, or when the panel is not reachable.

Find out why an address is blocked#

csf -g 198.51.100.23

This searches every list and live rule for the address and says where it matches: the deny list, a temporary block by LFD, or a country block. The panel's Find an address button does the same with unblock buttons.

Unblock an address#

csf -dr 198.51.100.23   # remove from the permanent deny list
csf -tr 198.51.100.23   # remove a temporary block (for example by LFD)

Always allow an address#

csf -a 198.51.100.23 "office"     # allowed through the firewall, never blocked

To stop LFD from counting failed logins for an address (for example a monitoring service) but keep port rules, add it to /etc/csf/csf.ignore and restart LFD:

echo "198.51.100.23 # uptime monitor" >> /etc/csf/csf.ignore
systemctl restart lfd

Block an address#

csf -d 203.0.113.99 "spam bot"          # permanent
csf -td 203.0.113.99 3600 "brute force" # one hour

Open or close a port#

Ports are listed in /etc/csf/csf.conf: TCP_IN, TCP_OUT, UDP_IN, UDP_OUT, and the same with 6 for IPv6. Edit the list, then reload:

grep -E '^(TCP|UDP)6?_(IN|OUT)' /etc/csf/csf.conf
nano /etc/csf/csf.conf
csf -r

A range is written 30000:30100. To open a port for one address only, add an advanced rule to /etc/csf/csf.allow, for example MariaDB from your office:

tcp|in|d=3306|s=198.51.100.23

Restart and status#

csf -r                     # reload the rules
systemctl restart lfd      # restart login protection
systemctl status csf lfd --no-pager
csf -v                     # version

If csf.conf still has TESTING = "1", CSF empties its rules every few minutes. The panel warns about this; run the intoPanel installer again to finish its setup.

Read the logs#

tail -n 50 /var/log/lfd.log                  # what LFD blocked and why
grep -i "198.51.100.23" /var/log/lfd.log     # history of one address

How many failed logins lead to a block#

Set this per service (panel, SSH, FTP, SMTP, POP3, IMAP) under Security → Sign-in Attack Protection in the panel, rather than in csf.conf by hand, so the two never disagree.

Frequently asked questions

A customer says the server is down, but it works for me. What should I check?

Their address is probably blocked after failed mail or FTP logins. Ask for their IP address (they can find it on any "what is my IP" site) and run csf -g with it, then csf -tr or csf -dr.

Should I use firewalld or ufw instead of CSF?

No. intoPanel manages CSF; running another firewall beside it leads to rules that contradict each other.

Are my manual rules kept when the panel updates?

Yes. Rules written by hand in csf.allow, csf.deny and csf.ignore are shown in the panel and kept, and updates do not reset your csf.conf values.

Was this article helpful?

Something missing? Ask in the community or open a ticket.