Question
How do I configure my firewall for cPanel & WHM?
Answer
Please note that you should only select ports required by the cPanel & WHM software and must ensure the server is configured to add back the firewall rules when the server is rebooted.
If you are not comfortable with performing firewall maintenance we recommend you work with a qualified System Administrator to minimize unforeseen events.
Before setting up, we recommend making sure that you have the best practices in place. Please make sure you have access to your server at all times, preferably from the system console or other out-of-band access.
- On a cPanel server, the default firewall management software should already be installed with the operating system. If these packages are for some reason not installed, you can install them with the following commands as the server's root user:
AlmaLinux, CloudLinux, or CentOS 7yum install firewalld
AlmaLinux, CloudLinux, or Rocky Linux 8dnf install firewalld
Ubuntu
apt install ufw
- Save the current iptables rules to a file. This creates a backup in case something unexpected occurs and will allow a quick reversion if necessary:
iptables-save > /root/iptables.save
-
Run the following built-in cPanel script to automatically configure the firewall rules:
/usr/local/cpanel/scripts/configure_firewall_for_cpanel
Comments
0 comments
Article is closed for comments.