How to Open a Port in Linux
Here, in this article, I will try to answer another common question in Linux, how to open a port. Linux users may try to open a port in Linux for various purposes and go through iptables and the firewalls to find out how can they access a particular port. Let us try to find out an answer to this question, how to open a port in Linux, in the following article...

- Linux: How to Find IP Address in Linux
- Linux: How to Change Password in Linux
- Linux: How to Find a File in Linux
The command to verify whether a port is open in Linux is as follows:
netstat -nap | grep : portno
where portno should be replaced with the numerical port number you want to check, if it is open or not.
From the output of this command, you can easily make out if a port is open or not in Linux.
How to Open a Port in Linux?
Now let us take a look at the query in Linux, how to open a port, for which you have reached this tutorial. Opening a port in Linux can be done with the following commands. For opening a TCP port, you can type the following command:
iptables -A INPUT -p tcp -dport portno -j ACCEPT
where portno needs to be replaced with the numerical port number that you want to open.
For opening a UDP port, type the following command:
iptables -A INPUT -p udp -sport portno -j ACCEPT
where portno needs to be replaced with the numerical port number that you want to open.
You may also find the following articles on Linux quite informative: Here, in this article, I have assumed that you have logged in as the root user. With this, I complete this article on Linux, how to open a port. Hope this article proves to be of some help to you.
Like This Article?
Follow:

Post Comment | View Comments


