How to open a port in Linux
Secure connection of network nodes and exchange information between them directly associated with open ports. Connection and traffic transfer is made through a specific port, and if it is closed, to execute such a process will not be possible. Because of this, some users are interested in forwarding one or more rooms for the setup of interaction devices. Today we show you how to perform the task in operating systems based on Linux kernel.
Open ports in Linux
Though in many distributions by default there is a built in tool for managing networks, all such decisions are often not able to fully implement the setting of the open ports. The instructions in this article will be based on the additional application called Iptables — a solution to edit the firewall settings using superuser rights. All builds of the OS on Linux it works the same, except that different command for mounting, but we’ll talk about that below.
If you want to know which of those ports are already open on your computer, you can use the built-in or additional console tool. Detailed instructions on how to find the necessary information you will find in our other article, clicking on the following link, and we begin step-by-step analysis of open ports.
Read more: Viewing open ports in Ubuntu
Step 1: Install Iptables and viewing rules
The Iptables utility is not natively included with the operating system, which it need to install from the official repository, and then to work with the rules and try to change them. Installation does not take much time and is accomplished through the standard console.




As you can see, in the distribution, now there is a team of iptables, responsible for the management of the eponymous utility. Again, what does this tool from superuser rights, so the string must contain the prefix sudo, and then the other values and arguments.
Step 2: Permit data exchange
No ports are not working properly, if it prohibits the exchange of information with their own firewall rules. In addition, the lack of necessary regulations in the future may cause various errors when forwarding, so we strongly suggest you to do the following:




The above-mentioned parameters you have provided the correct sending and receiving data, which will allow you to communicate with the server or another computer. You only have to open ports, through which will be implemented by the interaction.
Step 3: Open the necessary ports
You are already acquainted with the principle on which adds new rules to the Iptables configuration. There are several arguments that allow certain ports to be open. Let us explain this procedure on the example of popular port numbers 22 and 80.
sudo iptables -A INPUT -p tcp –dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp –dport 80 -j ACCEPT.




In the case when the administrator of the computer has made its own rules in the tool, organized relief packages at the approach to the point, for example, using sudo iptables -A INPUT -j DROP, you need to use another command sudo iptables: -I INPUT -p tcp –dport 1924-j ACCEPTwhere 1924 — the port number. It adds the necessary port in the beginning of the chain, and then the packets are discarded.

Then you can prescribe the same line of sudo iptables-L and make sure that everything is configured correctly.

Now you know how propisyvayutsya ports on Linux operating systems, for example, additional utility Iptables. We recommend to follow the emerging lines in the console when typing commands, it will help to detect any errors and eliminate them quickly.