Knowledgebase

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.

Use one firewall only. Imunify360 has its own firewall and works with the system firewall. Running several firewall managers side by side (for example CSF plus another tool) causes conflicting rules. If you are not sure which one your server uses, ask EgWeb support.

Part 1: Imunify360

Open WHM, then Plugins > Imunify360.

  1. 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.
  2. Block an IP: add it to the black list in the same tab.
  3. 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.
  4. 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

ServicePorts
Web80, 443
cPanel / WHM / Webmail (SSL)2083, 2087, 2096
Email25, 465, 587, 993, 995 (and 110, 143)
FTP21 plus the passive range
DNS53 (TCP and UDP)
SSH22 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.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • firewall, imunify360, csf, server security, whitelist ip, block ip, almalinux

Was this answer helpful?

0 Users Found This Useful