What is CSF
CSF is a free and advanced firewall for Linux distributions and Linux based VPS. In addition to the basic functionalities of a firewall, CSF includes other security features such as login, intrusion, and flood detections.
We can open ports in CSF by two methods as listed below.
1) Using the WHM interface.
2) Using the Command Line Interface.
Using the WHM interface
Let’s take a look on how to open a port in CSF with the help of WHM interface.
Steps to open port in CSF
1) Login to your WHM with the root password.
2) Go to the Plugins sections, click on the option ‘ConfigServer Security & Firewall’.
3) Click on the ‘Firewall Configuration’ button to enter into advanced settings.
4) In the coming window, go to the ‘IPv4 Port Settings’ section.
5) Now, edit the fields ‘Allow incoming TCP ports’ and ‘Allow outgoing TCP ports’
# Allow incoming TCP ports
TCP_IN = “20,21,22,25,26,53,80,110,143,443,465,587,993,995,2077”
# Allow outgoing TCP ports
TCP_OUT = “20,21,22,25,26,37,43,53,80,110,113,443,465,873,2087”
6) Save the changes made.
7) Restart the firewall.
This is how to add a port in the CSF using the WHM interface. Now let’s see how to open a port in the Command Line Interface.
Using the Command Line Interface
Steps to open port in CSF
1) Login to the server using the SSH.
2) Open the configuration file of the CSF as follows.
# vi /etc/csf/csf.conf
3) Add the required ports to the csf.conf file
# Allow incoming TCP ports
TCP_IN = “20,21,22,25,26,53,80,110,143,443,465,587,993,995,2077”
# Allow outgoing TCP ports
TCP_OUT = “20,21,22,25,26,37,43,53,80,110,113,443,465,873,2087”
4) Restart the CSF for the changes to take effect. Run the below command to restart the CSF.
# csf -r
This is how to open ports in the CSF with the help of WHM interface and Command Line Interface.