![]() |
|
Guide Fail2ban on CyberPanel 3.0: Brute-Force Protection Without CSF (Tested) - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CyberPanel (https://adminsforum.com/Forum-cyberpanel) +---- Forum: CyberPanel Guides & Tutorials (https://adminsforum.com/Forum-cyberpanel-guides-tutorials) +----- Forum: CyberPanel Security Guides (https://adminsforum.com/Forum-cyberpanel-security-guides) +----- Thread: Guide Fail2ban on CyberPanel 3.0: Brute-Force Protection Without CSF (Tested) (/Thread-guide-fail2ban-on-cyberpanel-3-0-brute-force-protection-without-csf-tested) |
Fail2ban on CyberPanel 3.0: Brute-Force Protection Without CSF (Tested) - JAY - 10-26-2026 Fail2ban on CyberPanel 3.0: Brute-Force Protection Without CSF (Tested) Older CyberPanel versions came with CSF (ConfigServer Security & Firewall), which also blocked IPs that kept guessing passwords. In CyberPanel 3.0 CSF is gone ( Code: /firewall/csfStep 1: See what's hitting your server First, how bad is it? Our test server had been online for two days: Code: journalctl -u ssh --since today | grep -c 'Failed password\|Invalid user'
journalctl -u ssh --since today | grep -oE 'from [0-9.]+' | sort | uniq -c | sort -rn | head -5Code: /var/log/auth.logCode: auth.logThe mail side gets the same treatment, just slower: Code: journalctl --since today | grep -c 'SASL LOGIN authentication failed'Step 2: Install fail2ban Code: apt-get install -y fail2ban
fail2ban-client statusGood news on Ubuntu 24.04: the package's own Code: /etc/fail2ban/jail.d/defaults-debian.confCode: backend = systemdCode: banaction = nftablesCode: sshdStep 3: Does it get along with CyberPanel's firewall? CyberPanel uses firewalld, which also works with nftables. Fail2ban puts its bans in its own table, Code: inet f2b-tableCode: inet firewalldFirewall changes are usually applied with a reload. We checked that fail2ban's bans survive one: Code: nft list tables
firewall-cmd --reload
nft list tablesCode: firewall-cmd --reloadCode: addr-set-sshdStep 4: The Postfix jail that sees nothing fail2ban comes with a Code: postfix-saslCode: postfix.serviceCode:
Code: printf '[Init]\njournalmatch = [email protected]\n' > /etc/fail2ban/filter.d/postfix.localCode: fail2ban-regex systemd-journal 'postfix[mode=auth]' | grep '^Lines'Code: dovecotCode: dovecot.serviceStep 5: Your settings in jail.local Never edit Code: jail.confCode: /etc/fail2ban/jail.localCode: [DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
ignoreip = 127.0.0.1/8 ::1
[sshd]
enabled = true
[postfix-sasl]
enabled = true
[dovecot]
enabled = true
[recidive]
enabled = true
Code: systemctl restart fail2ban
fail2ban-client status sshdThe Code: postfix-saslCode: Journal matches: [email protected]Step 6: Banned yourself? Unban We tested ban, check and unban with a documentation IP ( Code: 203.0.113.50Code: fail2ban-client set sshd banip 203.0.113.50 # ban by hand
fail2ban-client banned 203.0.113.50 # which jails ban this IP?
fail2ban-client unban 203.0.113.50 # remove it from all jailsCode: bannedCode: [['sshd']]Code: unbanCode: ignoreipWhat fail2ban doesn't cover here
More CyberPanel guides
Tested on CyberPanel 3.0 (build 8, OpenLiteSpeed edition) on Ubuntu 24.04 with fail2ban 1.0.2, October 2026. |