How to Manage Ports on VPS or Dedicated Server
Managing ports on a Dedicated or VPS server is done through the command line. You will use IPTables to open and close ports and set up other port rules. This article will explain how to manage ports on your VPS or Dedicated server.
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.
Click on any of the steps to jump to that point in the walkthrough and see more details.
Can You Give Me Access to Specific Port Numbers?
For security reasons, many unused ports are closed by default. Depending on the type of account or server you have, in addition to certain circumstances, some ports may be opened.
To access Firewalls and ports on your VPS or Dedicated server:
- Log in to WHM.
- Click and expand Plugins section on the WHM menu.
- Select the firewall option. A similar feature may be listed as follows: Firewall Administration or ConfigServer Security & Firewall.
- This will open up the Firewall management administration area.
A variety of options for server ports for your needs, such as:
- Open an outbound port.
- Open an inbound port.
- Whitelist an IP address.
- Blacklist an IP address.
- Manage Firewall Service.
- Add a custom iptables rule to a chain.
- Additional features also include 'add custom rules', 'custom firewall rules', 'delete rules', and even 'stop', 'start', and 'restart' firewall services.
What Port Numbers Can I Open? What Ports Can You Open?
On the plans where this is possible, a port could be open, as long as it is not used for a malicious purpose.
It is strongly recommend you only open ports for services that you use and use the SSL version of each service whenever possible.
Working with firewall rules and server ports, be sure to always include a way to log back in to your server, ensure you can still login, and always maintain (console) access to your server.
Other Methods to Configure Port Access
Depending on your server type and version, you can configure port access using the following alternative methods:
- Configuration - Through the GUI: How to configure ports using the GUI
- Configuration - Using the Command Line: How to configure ports using the command line
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 the 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.
- 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.
- Type
service iptables saveand press enter. - Type
service iptables restartand press enter.
Once IPTables restarts, your new port rule will take effect.
Summary
So, there you have it! You now know how to manage ports on your VPS or Dedicated server like a pro. With IPTables, you can tweak your server's accessibility, lock down potential security risks, and make sure your applications are running smoothly. Double-check your rules and proceed with caution.
If you need further assistance, Bluehost Chat Support is available 24 hours a day, 7days a week while Bluehost Phone Support is available 7 days a week from 7 am-12 midnight EST.
- Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
- Phone Support -
- US: 888-401-4678
- International: +1 801-765-9400
You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.