This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here

Skip to main content

Just Host Web Hosting Help

Manage Ports On Dedicated Or VPS Servers

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 https://my.Justhost.com/hosting/help/whm-login#root-password.


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 https://i.Justhost.com/cgi/admin/help_resource/edit/180 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 finishes restarting your new port rule will take effect.

Knowledgebase Article 158,762 views bookmark tags: close dedi dedicated iptables open ports vps


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

This article will explain how to create and manage users on Dedicated or VPS servers.
Knowledgebase Article 140,825 views tags: dedi dedicated users vps

How to fix inaccessible backups on Dedicated or VPS servers due to backup size.
Knowledgebase Article 129,513 views tags: backup dedi dedicated inaccessible loop stuck vps

This article will explain some common causes for 500 errors on Dedicated or V.P.S servers.
Knowledgebase Article 129,829 views tags: dedi dedicated error server vps

Related Help Content

This article will explain how to view the email logs on a Dedicated or VPS server. This may be usefull if you are experiencing trouble with your email.
Knowledgebase Article 147,973 views tags: dedi dedicated logs mail vps whm

This article will explain how to clear the outbound mail queue on a dedicated or VPS server.
Knowledgebase Article 147,976 views tags: dedi dedicated mail queue vps

How can I gain access to blocked ports? What port numbers can be opened?
Knowledgebase Article 190,035 views tags: access firewall outgoing port restrictions

This article will explain how to restart the email related services on a Dedicated or VPS server. This may be useful if you are experiencing trouble with your email.
Knowledgebase Article 143,792 views tags: dedi dedicated dovecot exim mail restart vps whm

If you suspect malicious content, hacks or a virus on your VPS/Dedicated account here are some tools located in your WHM that you can use.
Knowledgebase Article 194,072 views tags: clamav dedi dedicated malware virus vps

This article will explain how to configure your dedicated or VPS server to use the new (non legacy) backup system.
Knowledgebase Article 112,592 views tags: backup dedi dedicated vps

How to manage the SSL used for cPanel login through the WHM
Knowledgebase Article 221,550 views tags: cpanel dedicated install login manage server ssl

CSF is a firewall for VPS and Dedicated servers. CSF is not installed as part of our default images on VPS or Dedicated servers. This article describes how to install it yourself or request support do so.
Knowledgebase Article 89,428 views tags: configserver csf dedicated firewall security vps

** Google ad credits are only available to customers in the United States, Canada, and the United Kingdom at this time.

¹ VAT (Value Added Tax) is not included in our advertised price and will be charged separately and itemized on invoices and billing information. Standard VAT rates based on EU Member State regulations may apply. Learn more.