Configure el firewall CSF in your servidor

What is CSF?

CSF (ConfigServer Security Firewall) es el firewall más usado en servidores with cPanel/WHM. Protege your servidor bloqueando IPs maliciosas, previniendo ataques de fuerza bruta and controlando qué ports están abiertos.

Install CSF

cd /usr/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

Ports importants a mantener abiertos

Edita /etc/csf/csf.conf and asegúrate de tener estos ports en TCP_IN and TCP_OUT:

  • 20, 21 — FTP
  • 22 — SSH
  • 25, 465, 587 — Email (SMTP)
  • 80, 443 — Web (HTTP/HTTPS)
  • 110, 995 — POP3
  • 143, 993 — IMAP
  • 2082, 2083 — cPanel
  • 2086, 2087 — WHM

Comandos basics de CSF

csf -r # Restartr firewall
csf -s # Iniciar firewall
csf -f # Detener firewall (emergencia)
csf -a 1.2.3.4 # Permitir IP
csf -d 1.2.3.4 # Bloquear IP
csf -dr 1.2.3.4 # Desbloquear IP

Activate mode no TESTING

By default CSF arranca en mode TESTING (se desactiva cada 5 min). Cuando estés listo, en /etc/csf/csf.conf cambia:

TESTING ="0"

Luego reinicia: csf -r

⚠️ Before de salir of the TESTING: Asegúrate de que your IP esté in the whitelist (/etc/csf/csf.allow) for no bloquearte a ti mismo.