Occasionally you will find that you need to open up a port in your firewall for some application or another. Depending on which firewall is installed on your server, there are several ways to go about this.
CSF (ConfigServer Security & Firewall) : CSF can be configured in Web Host Manager (WHM) as well as over ssh.
[1] Open up the following file:
Quote/etc/csf/csf.conf
[2] Add the port you mean to open to the needed line:
Quote# Allow incoming TCP ports
TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,26"
# Allow outgoing TCP ports
TCP_OUT = "20,21,22,25,37,43,53,80,110,113,443,587,873"
[3] CSF then needs to be restarted for the change to take effect:
Quotecsf -r
APF (Advanced Policy Firewall) : APF can only be configured by accessing the server over ssh, as the root user. Once in your server, Follow the steps below.
[1] Open the following file in your favorite text editor:
Quote/etc/apf/conf.apf
[2] Search the following line:
Quote# Common inbound (ingress) TCP ports
IG_TCP_CPORTS="20,21,22,25,53,80,110,143,443,465,993,995"
[3] After saving and closing out of your text editor, you will need to restart APF. This is as simple as running:
Quoteapf -r
WHM (Web Host Manager) :
Quote[1] Type configserver in the Find bar in the upper left hand corner.
[2] Click on ConfigServer Security&Firewall.
[3] On that page, click on the Firewall Configuration button:
[4] That page will allow you to edit the exact same file you would if you were accessing it over ssh:
[5] Like with the ssh instructions, add the necessary port to the list.
[6] Then click Change at the bottom of the page to save your changes.
[7] After that is run, you will need to restart csf. Thankfully, the very next screen you can see there is a button for that, Restart csf+lfd.
Closing ports : Closing ports in either firewall are as simple as removing the port from the list in the configuration file, and restarting the firewall.