Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open port in Linux [closed]

I have installed and web application which is running on port 8080 on RHEL (centOS). I only have command line access to that machine. I have tried to access that application from my windows machine from which I am connected to server via command-line, but it is giving connection time out error.

Then I have tried to open port 8080. I have added following entry into the iptables.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

After adding this into the iptables I have restarted it with - /etc/init.d/iptables restart

But still I am not able to access that application from my windows machine.

Am I doing any mistake or missing something?

like image 779
Niraj Chapla Avatar asked Sep 26 '13 17:09

Niraj Chapla


People also ask

How do I open a closed port?

Answer: From the Control Panel, navigate to System and Security, and click on Windows Firewall. Go to the Advanced settings and right-click on Inbound Rules on the left pane. Select New Rule, add the port and click Next. Pick the Protocol and the Port Number, click Next again.

What is the command to open ports in Linux?

The procedure to list open ports in Linux is as follows: Open the terminal application. Use command netstat -tulpn to open ports. Another option is to run ss -tulpn to open ports on modern Linux distros.


1 Answers

The following configs works on Cent OS 6 or earlier

As stated above first have to disable selinux.

Step 1 nano /etc/sysconfig/selinux

Make sure the file has this configurations

SELINUX=disabled  SELINUXTYPE=targeted 

Then restart the system

Step 2

iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT 

Step 3

sudo service iptables save 

For Cent OS 7

step 1

firewall-cmd --zone=public --permanent --add-port=8080/tcp 

Step 2

firewall-cmd --reload 
like image 164
Nirojan Selvanathan Avatar answered Sep 21 '22 19:09

Nirojan Selvanathan