Cloud House Technologies Logo
CloudHouse Technologies
HomeServicesProjectsBlogAbout UsCareersContact UsLogin
    Cloud House Technologies Logo
    CloudHouse Technologies
    HomeServicesProjectsBlogAbout UsCareersContact UsLogin

    How to Set Up CSF Firewall in Webmin: Complete Security Configuration Guide

    Priya

    Content Writer & Researcher

    Last Updated: 25 June 2026
    How to Set Up CSF Firewall in Webmin: Complete Security Configuration Guide
    🖥️

    Struggling to Keep Your Webmin Server Secure From Attacks?

    CloudHouse's server hardening experts configure and monitor CSF, Fail2Ban, and firewall rules 24/7 — so you can stop firefighting security incidents and focus on growing your hosting business. Let's lock down your server today.

    🔧 Book Free DiagnosisCall NowWhatsApp
    🖥️12,400+PCs Fixed
    ⭐4.9★Google Rating
    ⚡<15 minAvg. Response
    🛡️ISO 27001Certified

    Managing server security on a Webmin-powered Linux server requires more than just keeping software updated. Without a properly configured firewall, your server is exposed to brute force attacks, port scans, and unauthorized access attempts around the clock. ConfigServer Security & Firewall (CSF) is the industry-standard firewall solution for Webmin environments — and setting it up correctly can mean the difference between a secure hosting infrastructure and a compromised server.

    This guide walks you through the complete Webmin CSF firewall setup process: from installation and initial configuration to advanced rate limiting, monitoring, and troubleshooting common issues that hosting companies run into every day.

    Understanding CSF Firewall Architecture in Webmin

    CSF (ConfigServer Security & Firewall) is a stateful packet inspection (SPI) firewall built on top of iptables/nftables. Unlike a basic firewall script, CSF includes Login Failure Daemon (LFD), which monitors log files for authentication failures and automatically blocks offending IPs — similar to Fail2Ban but tightly integrated with cPanel, Webmin, and WHM panels.

    For web hosting companies running Webmin, CSF offers several critical advantages:

    • Webmin UI integration — manage all firewall rules from within the Webmin interface without touching the command line
    • LFD integration — automatic IP blocking on SSH, FTP, SMTP, and web panel brute force attempts
    • Port flood protection — rate limiting to stop SYN floods and connection abuse
    • Process tracking — detect and alert on suspicious processes that may indicate compromise
    • Email alerting — real-time notifications when IPs are blocked or system events trigger

    CSF operates in two modes: Testing Mode (firewall rules applied but not yet permanent — the firewall auto-disables itself after 5 minutes to prevent lockouts) and Live Mode (rules are permanent). Always start in Testing Mode when first configuring CSF on a production server.

    💡 None of these worked? Skip the guesswork.

    Get Expert Help →

    Installing CSF on Your Webmin Server

    Before installing CSF, ensure your server meets the prerequisites. CSF works on CentOS, AlmaLinux, Rocky Linux, Ubuntu, and Debian-based systems running Webmin.

    1Check kernel modules are available

    CSF requires iptables and specific kernel modules. Verify they're available:

    modprobe ip_tables
    modprobe iptable_filter
    lsmod | grep ip_tables
    2Download and install CSF
    cd /tmp
    wget https://download.configserver.com/csf.tgz
    tar -xzf csf.tgz
    cd csf
    sh install.sh
    3Verify Perl modules required by LFD
    perl /usr/local/csf/bin/csftest.pl

    This script checks for all required Perl modules. Any failures listed as REQUIRED must be resolved before CSF will function correctly. Install missing modules via your distribution's package manager (cpan, apt, or yum).

    4Enable the Webmin CSF module

    After installation, open Webmin and navigate to Webmin → Webmin Modules → Install Module. The CSF module is bundled with the installation and should appear automatically under Others → ConfigServer Security & Firewall. If it doesn't appear, refresh the Webmin modules list.

    1Keep Testing Mode enabled until configuration is complete

    In csf.conf, confirm TESTING = "1" — this prevents permanent lockout while you configure rules.

    2Configure allowed inbound ports (TCP_IN)

    Adjust TCP_IN to match your server's services. A typical web hosting server needs:

    TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,2222,10000"

    Port breakdown: 20-21 (FTP), 22 (SSH — change if using non-standard port), 25/465/587 (SMTP), 53 (DNS), 80/443 (HTTP/HTTPS), 110/143/993/995 (POP3/IMAP), 2222 (alternative SSH), 10000 (Webmin).

    3Configure allowed outbound ports (TCP_OUT)
    TCP_OUT = "20,21,22,25,43,53,80,110,113,443,587,993,995"

    Port 43 is required for WHOIS lookups; port 113 (ident) prevents SMTP delays on some mail servers.

    4Set LFD trigger thresholds

    LFD_TRIGGER determines how many failures before an IP is blocked. For hosting servers:

    LT_SSH = "5"      # Block after 5 failed SSH attempts
    LT_FTP = "10"     # Block after 10 failed FTP attempts
    LT_SMTP = "10"    # Block after 10 failed SMTP attempts
    LT_POP3 = "10"    # Block after 10 failed POP3 attempts
    5Whitelist your management IPs before going live

    Add your office/management IP addresses to /etc/csf/csf.allow:

    echo "YOUR.OFFICE.IP.HERE # Management IP" >> /etc/csf/csf.allow

    This is critical — failing to whitelist your IP before disabling Testing Mode can lock you out of your own server.

    Advanced CSF Features: Rate Limiting, DDoS Protection, and Process Tracking

    For hosting companies managing multi-tenant servers, CSF's advanced features provide protection that basic firewalls can't match.

    Connection Rate Limiting (CONNLIMIT)

    Prevent any single IP from opening too many simultaneous connections to a service:

    CONNLIMIT = "22;5,80;50,443;50"

    This limits SSH to 5 simultaneous connections per IP, and HTTP/HTTPS to 50. Adjust based on your legitimate traffic patterns.

    Port Flood Protection (PORTFLOOD)

    Block IPs that make too many connection attempts in a short time window:

    PORTFLOOD = "80;tcp;20;5,443;tcp;20;5"

    This blocks any IP making more than 20 TCP connections to port 80 or 443 within 5 seconds — effective against basic HTTP flood attacks.

    Syn Flood Protection

    SYNFLOOD = "1"
    SYNFLOOD_RATE = "100/s"
    SYNFLOOD_BURST = "150"

    Process Tracking (PT_USERPROC)

    LFD can monitor running processes and alert when a user's processes exceed thresholds — useful for detecting runaway scripts or malicious activity:

    PT_USERPROC = "10"     # Alert if user runs more than 10 processes
    PT_USERMEM = "200"     # Alert if user process uses more than 200MB
    PT_USERTIME = "1800"   # Alert if process runs longer than 30 minutes

    Directory Watching (PT_DELETED)

    Enable this to detect deleted files that are still being executed — a common indicator of rootkit activity:

    PT_DELETED = "1"

    Monitoring, Alerting, and Managing CSF Blocks in Webmin

    Once CSF is live, monitoring blocked IPs and responding to false positives is part of daily server management. The Webmin CSF module makes this straightforward.

    Viewing blocked IPs

    Navigate to Others → ConfigServer Security & Firewall → Temporary IP Bans in Webmin to see all currently blocked IPs with timestamps and reasons. You can unblock IPs directly from this interface.

    From the command line:

    csf -l      # List all current iptables rules
    csf -t      # Show temporary IP bans
    csf -tr 1.2.3.4   # Remove specific IP from temporary ban

    Permanently allow or deny IPs

    csf -a 1.2.3.4 "Trusted monitoring server"   # Add to permanent allow
    csf -d 1.2.3.4 "Known attacker"              # Add to permanent deny

    Email alerting configuration

    Set LF_ALERT_TO in csf.conf to receive email notifications for blocks, process alerts, and security events:

    LF_ALERT_TO = "admin@yourdomain.com"
    LF_ALERT_FROM = "csf@yourserver.com"

    Checking LFD logs

    tail -f /var/log/lfd.log

    Common troubleshooting scenarios:

    • Legitimate user blocked — Check /var/log/lfd.log to see why they were blocked, then add their IP to csf.allow
    • CSF blocking your own monitoring server — Add monitoring server IPs to /etc/csf/csf.ignore to prevent LFD from tracking its connection attempts
    • Port not accessible after CSF install — Run csf -l | grep PORT_NUMBER to check if rules exist; add port to TCP_IN if missing
    • LFD not starting — Check systemctl status lfd and verify all Perl modules are installed via perl /usr/local/csf/bin/csftest.pl

    Going Live: Disabling Testing Mode and Final Checks

    Before disabling Testing Mode, run through this checklist:

    • Your management/office IP is in /etc/csf/csf.allow
    • All required ports for your services are in TCP_IN and TCP_OUT
    • LFD thresholds are tuned to avoid blocking legitimate users
    • Alert email is configured and tested
    • You have console/IPMI access as a backup in case of lockout

    When ready, disable Testing Mode:

    csf -x   # Disable Testing Mode
    csf -e   # Enable CSF in live mode
    csf -r   # Restart CSF with new configuration

    Or from the Webmin interface: navigate to ConfigServer Security & Firewall → Firewall Configuration, set TESTING to Off, and click Save Settings, then Restart CSF+LFD.

    Verify the firewall is active:

    csf -l | head -30
    systemctl status csf lfd

    FAQs

    Q: Can I run CSF alongside Fail2Ban on a Webmin server?

    A: Yes, but it requires careful configuration to avoid conflicts. Both tools modify iptables rules, and both monitor log files for authentication failures. If running both, configure them to monitor different services — or disable Fail2Ban's SSH monitoring and let LFD handle it exclusively to avoid duplicate bans and rule conflicts.

    Q: Why is CSF in Testing Mode auto-disabling itself every 5 minutes?

    A: This is by design — Testing Mode disables the firewall every 5 minutes to prevent permanent lockout while you're configuring rules. This is not a bug. Once you've verified your configuration and whitelisted your management IPs, disable Testing Mode to make rules permanent.

    Q: How do I update CSF to the latest version?

    A: Run the built-in update command: csf -u. This downloads and applies the latest CSF version without losing your configuration. Check your current version with csf -v.

    Q: What ports should I open for a server running Webmin only (no mail server)?

    A: A minimal Webmin-only server needs: 22 (SSH), 80 (HTTP), 443 (HTTPS), 10000 (Webmin). If using Virtualmin, also add 20000 (Usermin). Remove 25, 110, 143, and all mail ports if your server doesn't handle email.

    Q: CSF is blocking a legitimate IP that connects frequently — how do I whitelist it without disabling protection?

    A: Add the IP to /etc/csf/csf.ignore (not csf.allow). The csf.ignore file tells LFD to ignore connection attempts from that IP when counting failures, without adding a permanent allow rule to the firewall. This means the IP is still subject to firewall rules but won't be auto-blocked by LFD for connection frequency.

    Managing a Webmin server securely is an ongoing effort. If your team is spending too much time responding to attacks, blocked IPs, and security incidents instead of growing your business, CloudHouse's server hardening service can take that burden off your plate — with 24/7 monitoring, proactive CSF tuning, and expert response to security events.

    Get the Free Linux Server Admin Cheatsheet (PDF)

    Essential commands for server management, networking, and troubleshooting — all on one printable page.

    Running Linux servers? Let us manage them for you.

    Our Managed Linux Server plans cover updates, security hardening, monitoring, and 24/7 incident response — so your servers stay up and your team stays focused.

    • Proactive OS patching and security updates
    • 24×7 monitoring with instant alerting
    • Backup configuration and disaster recovery
    • Dedicated Linux engineers on call
    See Pricing Plans →

    What our customers say

    “Our production server went down at 2 AM. CloudHouse had it back online in under 20 minutes. Incredible response time.”

    Arun S.

    CTO, SaaS Startup

    “They migrated our entire infrastructure from Ubuntu 18 to 22 with zero downtime. Couldn't have asked for better.”

    Deepak N.

    DevOps Lead

    Frequently Asked Questions

    Yes, but it requires careful configuration to avoid conflicts. Both tools modify iptables rules and monitor log files for authentication failures. If running both, configure them to monitor different services — or disable Fail2Ban's SSH monitoring and let LFD handle it exclusively to avoid duplicate bans and rule conflicts.

    Book your free 15-minute diagnosis

    A certified technician will call you back within 15 minutes during business hours.

    Share this article

    Leave a Comment

    Comments (0)

    Loading comments...

    Need Help Hardening Your Webmin Server?

    CSF misconfiguration is one of the most common causes of server lockouts and security breaches in Webmin environments. Our team has configured CSF for hundreds of hosting servers — we know every edge case. Get in touch for a free security review.

    Call Now — FreeWhatsApp Us

    Why CloudHouse?

    • ISO 27001:2022 certified
    • 12,400+ devices supported
    • 4.9★ on Google
    • Sub-15-minute response

    CloudHouse Technologies

    Innovative cloud solutions for modern businesses. We deliver cutting-edge technology with exceptional service.

    Contact Us

    CloudHouse Technologies Pvt.Ltd
    Special Economic Zone(SEZ),
    Infopark Thirissur,4B-15,
    Indeevaram,Nalukettu Road,
    Koratty, Kerala, India-680308
    0480-27327360
    info@cloudhousetechnologies.com

    Quick Links

    • Our Services
    • Gold Loan Software
    • About Us
    • Contact
    • Terms and Conditions
    • Privacy Policy
    ISO27001:2022
    Certified

    © 2026 CloudHouse Technologies Pvt.Ltd. All rights reserved.

    Back to top