Open Ports in Linode Server

Open Ports in Linode Server
This tutorial focuses on the steps to open ports in Linode Server using iptables and UFW.

 

Linode is an American-based cloud hosting company that offers Virtual Private Servers (VPS). The company’s name, “Linode”, is a portmanteau of the words “Linux” and “node”. Linode is the most comprehensive and independent open cloud provider serving businesses of all sizes. Cloud computing is the delivery of computing services, such as storage, servers, networking, databases, intelligence, software, analytics, etc., over the cloud. The mission of Linode Cloud is to accelerate innovation by making cloud computing simple and accessible to everyone. Linode Cloud offers flexible resources, faster innovation, and economies of scale to all their customers. While using Linode cloud services, customers only need to pay for what they use, helping reduce the operating costs. In addition, Linode also helps to run the application infrastructure more efficiently. All the users of Linode Cloud can scale up or down the resources whenever the business asks for them.

Securing Linode servers against attacks is crucial. One of the best policies here would be to close all ports and keep only the required ports open. In order to open a custom port, the user needs to modify the server firewall. Unfortunately, users can even lose the Linode server connection with a bad firewall edit. In this tutorial, we will learn the steps to open and close ports in Linode Server using iptables, UFW, and Firewalld.

 

>> Note: Making the Linode application’s network ports public is a significant security risk. We strongly advise only allowing access to those ports from trusted networks. Suppose users need to access applications outside of a trusted network for development purposes, do not allow access to those ports using a public IP address. Instead, use a reliable and secure channel such as an SSH tunnel or a VPN.

 

When to Open Port in Linode Servers?

Users need to open a port mainly when an application is running on the user Linode servers custom port. Some Linode server owners run common applications, such as mail service, SSH, etc., on alternate ports for security reasons. In that situation also, users need to open the specific port in the Linode server firewall.

Whatever be the situation, users need to open the port without compromising the server security for the service to work correctly.

 

Methods to Open Ports in Linode Server

Luckily, there are different methods to open ports in the Linode server. And these methods have various complexity levels too. Some of the methods offered to open ports in Linode servers are the following:

 

Method 1: Using iptables

The iptables method is the most commonly used way to modify the Linode server firewall. This method requires expert knowledge about the iptables rule formats. Any wrong command execution can result in making the entire server unreachable.

That’s why our support engineers always double-check the iptables rules before saving them.

 

Open an Incoming Port

The iptables command to open an incoming port on the Linode server would be:

 

# iptables -A INPUT -p tcp --dport <port_number> -j ACCEPT

 

For example, if the user wants to open port 2525 on the server, execute the following command:

 

# iptables -A INPUT -p tcp --dport 2525 -j ACCEPT

 

After executing the above command, save the firewall rules by running the following command:

 

# service iptables save

 

 

Open an Outgoing Port

The iptables command to open an outgoing port on the Linode server would be:

 

# iptables -A OUTPUT -p tcp –dport <port_number> -j ACCEPT

 

 

For example, if the user wants to open port 2525 on the server, execute the following command:

 

# iptables -A OUTPUT -p tcp --dport 3032 -j ACCEPT

 

 

After executing the above command, save the firewall rules by running the following command:

 

# service iptables save

or

# /etc/init.d/iptables save

 

 

Method 2: Using UFW

Adding iptables rules ideally needs considerable expertise. Therefore, some Linode owners may not be comfortable using the iptables rule to open or close ports. In such situations, our support engineers recommend using another firewall program called Uncomplicated Firewall (UFW).

In order to open a port in the Linode server using UFW, execute the following command:

 

# ufw allow <port_number>/tcp

 

In order to open port 2525 in the Linode server using UFW, execute the following command:

 

# ufw allow 2525/tcp

 

In order to open a port range in the Linode server using UFW, execute the following command:

 

# ufw allow <port range from>:<port range to>/tcp

 

Example:

# ufw allow 7100:7200/tcp

 

 

How can a user fix the Linode port connectivity issue?

Till now, we saw two different ways to open a port in the Linode server. However, customers often report connectivity problems on custom ports.

In order to troubleshoot and fix port restrictions in the Linode server, follow the below process:

As the primary step, check and ensure that the port is listening inside the Linode server. For that, execute the following command:

 

# netstat -ltn

 

The above command would list all the listening service ports on the Linode server. If this allows connection on a specific port, we know that it is a server firewall issue. Further, if there are connection problems, we try disabling the Linode server firewall temporarily.

A telnet command to the port will resemble similar to the one shown below when there are firewall restrictions:

 

Trying 50.xx.xx.241...

telnet: connect to address 50.xx.xx.241: No route to host

 

Occasionally, we suggest customers check from an alternative network. This would help the support engineers to isolate the problems with the customer’s network.

After making changes to the server firewall and customer network, the connection to the port will work fine. And it results in a successful connection.

 

Conclusion

This tutorial presents the steps to open ports in Linode Server using iptables and UFW. Hope this tutorial was helpful, and do reach out to us if you have any queries or suggestions.

 

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Managed Linode Services

Focus on your business, and let us take care of your Linode Servers!
From what you are reading, it seems you are interested in Linode and related technologies. If you have a moment to spare, please take a look at our Managed Linode plan, which might interest you even more!
Managed Linode

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

Introducing - WPHealers!

Complete WordPress Management, 24x7 Support & White Label Agency Plans!

WordPress migration service, security, white-label reseller services and lot more! Grab the introductory deals now!

WPHealers

ServerHealers uses cookies.