4 mins read

How to Open a Port in CSF Firewall via WHM/cPanel?

Ports are centers where the IP addresses and Internet Protocols with the destination or origination address start a communication session. Ports are part of the client-server model and have a 16-digit number for their identification. Needless to say, the CSF firewall needs configuration to open a port considering the security of the server.

If you are a user with a cPanel server, you can customize the port settings of the CSF firewall with WHM.

What is a port

A port is a process-specific or an application-specific software construct serving as a communication endpoint. It is used by the transport layer protocols of the Internet Protocols suite such as UDP and TCP. The term port is also used in the hardware devices. They are the physical setup of the systems to get connected with another hardware media. Here, we are going to see about the logical construct that identifies a specific process or network service. An IP address and a protocol will be always associated with the ports and thus completes the destination or origination address of a communication session.

Normally, a port is identified for each address and protocol by a port number. The port number is a 16-bit number. Usually, various port numbers are used to identify various services. There are thousands of ports and among them 1024 are reserved by convention to identify specific service types by a host. In the client-server model of application architecture, the ports that network clients connect for service initiation provide a multiplexing service. After initial communication binds to the well-known port number, this port is freed by switching instances of service requests to a dedicated connection-specific port number, so that additional clients can be serviced. In this article, we are going to see how to open ports in CSF with WHM.

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.

Log into WHM:

  • Access your WHM by navigating to https://your-server-ip:2087 in your web browser.
  • Enter your WHM username and password to log in.
Open Port in CSF Firewall

Access CSF Firewall Configuration:

  • In WHM, navigate to Plugins in the sidebar.
  • Click on ConfigServer Security & Firewall.

Edit CSF Configuration:

  • Once you’re in the CSF interface, click on Firewall Configuration.

Find the Port Configuration Section:

  • Scroll down to find the section for TCP_IN and TCP_OUT for incoming and outgoing connections respectively.
  • You can also configure UDP_IN and UDP_OUT if you need to open a UDP port.

Open port in CSF Firewall :

  • In the respective field (TCP_IN for incoming, TCP_OUT for outgoing), Open port in CSF Firewall you wish to open.
  • Separate multiple port numbers with a comma. For example, to Open port in CSF Firewall 8080 for incoming connections, you would add 8080 to the TCP_IN field.

Save and Restart CSF:

  • After adding the port, scroll down and click on Change to save the configuration.
  • You will be prompted to restart the firewall for changes to take effect. Click on Restart csf+lfd.
  • Verify the Port is Open:
  • You can verify if the port is open by using tools like telnet, nmap, or other port scanning tools to check the port status from an external system.

That’s it! You’ve successfully opened a port in CSF Firewall via WHM/cPanel.