MilesWeb Hosting Forum

Web Hosting Technical Support => How To's => Topic started by: saurabhj on July 20, 2015, 07:41:03 PM

Title: How To Open and Close Port 25 In Your Firewall ?
Post by: saurabhj on July 20, 2015, 07:41:03 PM
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:                           

[2] Add the port you mean to open to the needed line:               
      # 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:
       csf  -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:

[2] Search the following line:
   # Common inbound (ingress) TCP ports

[3] After saving and closing out of your text editor, you will need to restart APF. This is as simple as running:
   apf -r

WHM (Web Host Manager) :
[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.