1. bluehost knowledge base

VPS & Dedicated Hosting: Manage Ports

Overview

Managing ports on a Dedicated or VPS server is done through command line. You will use IPTables to open and close ports and setup other port rules. This article will explain how.

This requires knowing the root password for your server. If you don't know the root password or haven't set one up, please see Log into WHM.


The General Steps Involved in Updating Port Rules

Click on any of the steps to jump to that point in the walkthrough and see more details.


Creating the Rule

Creating a new rule for IPtables can be confusing. Fortunately, there is an automatic rule generator that can make the process much simpler. It lets you enter the port information and then gives you the command to add that rule to IPTables. Use the following link to generate a rule:

http://www.perturb.org/content/iptables-rules.html

TIP: Leave the SRC and Dest boxes blank unless you know you need them.

Example: If you were trying to open port 64738, the command to add that rule would be: 
iptables -A INPUT -m tcp -p tcp --sport 64738 -j ACCEPT
 

Accessing Command Line

You can access command line through SSH using software like Putty on Windows or Terminal on Mac. Please see SSH Access for detailed information about how to connect using SSH.
 

Updating IPTables with the new Rule

Once you have command line access, you just need to enter the commands to add your new rule to IPTables.

  1. Enter the command to update IPTables. If you used perthub.org to create the rule, enter each line from the output box into the console one at a time.
  2. Type service iptables save and press enter.
  3. Type service iptables restart and press enter.

Once IPTables restarts, your new port rule will take effect.