How to manage your server firewall with Imunify360 or CSF
This guide shows you how to configure your server firewall with Imunify360 or CSF on a cPanel/WHM server running AlmaLinux: how to allow or block IP addresses, open ports, and unblock yourself if you get locked out. A well-configured firewall stops brute-force attacks while keeping your clients connected.
Part 1: Imunify360
Open WHM, then Plugins > Imunify360.
- Allow an IP (whitelist): go to the Firewall tab, choose the white list, click add, enter the IP or range and a comment such as "office". Whitelisted IPs are not blocked for failed logins.
- Block an IP: add it to the black list in the same tab.
- Find why an IP is blocked: search the IP in the gray list or black list. The gray list holds IPs blocked automatically; remove one to unblock it.
- Settings: the Settings tab controls things like brute-force protection and CAPTCHA behaviour. Change them carefully and note what you changed.
The same actions from SSH:
imunify360-agent ip-list local add --purpose white 203.0.113.25 --comment "office"
imunify360-agent ip-list local add --purpose drop 198.51.100.7 --comment "attacker"
imunify360-agent ip-list local list --by-ip 203.0.113.25
Part 2: CSF (ConfigServer Security & Firewall)
Some servers use CSF. Its original developer stopped working on it in 2025 and it is now maintained by the community, so check with support before installing it on a new server. If your server has it, open WHM > Plugins > ConfigServer Security & Firewall, or use SSH:
csf -a 203.0.113.25 office # allow an IP
csf -d 198.51.100.7 attacker # block an IP
csf -dr 198.51.100.7 # remove a block
csf -g 203.0.113.25 # search for an IP in the rules
csf -r # reload the rules
To open a port, edit /etc/csf/csf.conf, add it to TCP_IN (incoming) or TCP_OUT (outgoing), save and run csf -r. After the first setup, make sure TESTING = "0", otherwise the rules are cleared every few minutes.
Ports a cPanel server normally needs
| Service | Ports |
|---|---|
| Web | 80, 443 |
| cPanel / WHM / Webmail (SSL) | 2083, 2087, 2096 |
| 25, 465, 587, 993, 995 (and 110, 143) | |
| FTP | 21 plus the passive range |
| DNS | 53 (TCP and UDP) |
| SSH | 22 or your custom port |
Do not close ports you are not sure about. If you change the SSH port, open the new one first (see How to change the SSH port and disable root password login).
Common problems
- A client cannot open cPanel or email suddenly: their IP was probably blocked after wrong passwords, often from an old saved password in a phone. Ask for their IP (they can search "what is my IP") and unblock it, then fix the saved password.
- You locked yourself out: connect from a different network or the VPS console and remove the block, or open a ticket with your IP.
- A new service does not work: its port is closed. Open only the port it needs.
For a full checklist, see How to secure your Linux server.
Frequently asked questions
Should I whitelist my office IP?
Only if it is a fixed IP. Home and mobile connections usually change IP, so a whitelist entry would later allow someone else.
Will a firewall slow down my websites?
No noticeable effect for normal traffic. It actually saves resources by stopping attack traffic early.