How to open a port? 3000

Issues related to configuring your network
User avatar
peopleinside
Posts: 62
Joined: 2013/11/13 10:41:22

How to open a port? 3000

Post by peopleinside » 2019/12/01 12:02:46

Hi, I'm experiencing issue on opening a port.
I'm on Centos 7.x

I followed all guides found on Google but still not able to open port 3000
On Centos 7 seems you have to use firewall-cmd but is not installed on my server so i suppose if the port is not open is not closed by this but from iptables.

I tried

Code: Select all

iptables -A INPUT -i eth0 -p tcp --dport 3000 -j ACCEPT
saved and restarted iptables but nothing port still be seen closed.

Any idea?
I cannot understand...

In the oputput of iptables-save I have:

Code: Select all

-A OUTPUT ! -o lo -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT
-A INPUT ! -i lo -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT
checking the port still be closed.

User avatar
TrevorH
Forum Moderator
Posts: 27156
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to open a port? 3000

Post by TrevorH » 2019/12/01 12:41:56

If you're not using firewalld tehn you are probably using plain iptables. If so then the rule you added went at the end of the chain, after the final existing one that rejects all connections so it would never be used. You need to `iptables -I INPUT nn` insert the rule at line number nn.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
peopleinside
Posts: 62
Joined: 2013/11/13 10:41:22

Re: How to open a port? 3000

Post by peopleinside » 2019/12/01 12:45:46

Thanks for the reply. Can you suggest steps to do?
Sorry :)

I have to print a list with a command than find the right line and do the command with the desired line?
I do in the past but i cannot remember steps to do.
Thanks

User avatar
jlehtone
Posts: 2432
Joined: 2007/12/11 08:17:33
Location: Finland

Re: How to open a port? 3000

Post by jlehtone » 2019/12/01 13:37:38

Code: Select all

iptables --lin -nL

User avatar
peopleinside
Posts: 62
Joined: 2013/11/13 10:41:22

Re: How to open a port? 3000

Post by peopleinside » 2019/12/01 13:52:16

Thanks, now i see the lines with iptables --lin -nL what to do?
>.<

I used now:

Code: Select all

iptables -I INPUT -m state --state NEW -p tcp --dport 3000 -j ACCEPT
saved, and restarted iptables still not working.

User avatar
jlehtone
Posts: 2432
Joined: 2007/12/11 08:17:33
Location: Finland

Re: How to open a port? 3000

Post by jlehtone » 2019/12/01 15:40:16

man iptables wrote: -I, --insert chain [rulenum] rule-specification
Insert one or more rules in the selected chain as the given rule number. So, if the rule number is 1,
the rule or rules are inserted at the head of the chain. This is also the default if no rule number is
specified.
You did not specify rule number. Therefore, you did use:

Code: Select all

iptables -I INPUT 1 -m state --state NEW -p tcp --dport 3000 -j ACCEPT
What are your rules after restart? Show output of

Code: Select all

iptables -S INPUT

How do you determine whether something "works"?

User avatar
peopleinside
Posts: 62
Joined: 2013/11/13 10:41:22

Re: How to open a port? 3000

Post by peopleinside » 2019/12/01 16:29:52

With your command now the line are first.
I use https://ping.eu/port-chk/ still be closed.

User avatar
TrevorH
Forum Moderator
Posts: 27156
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to open a port? 3000

Post by TrevorH » 2019/12/01 16:39:55

You know that you also have to have something that listens on the port before it will appear to be open? What does ss -antup | grep 3000 say?
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
peopleinside
Posts: 62
Joined: 2013/11/13 10:41:22

Re: How to open a port? 3000

Post by peopleinside » 2019/12/01 16:42:36

Said nothing, blank line.
I would like the port 3000 for NodeJS

aks
Posts: 2859
Joined: 2014/09/20 11:22:14

Re: How to open a port? 3000

Post by aks » 2019/12/01 17:14:37

Start your app as you need a listener on port 3000.
ss -antl | grep 3000
to check the listener is established.
Then telnet (or whatever you want) to confirm you can connect to the port internally (and that something like SELinux is not tripping you up).
Then try from outside the machine to connect to that port, if it fails, switch the firewall off and try again. If it works, then the firewall is the problem, if it still doesn't work, there's a network problem.

Post Reply

Return to “CentOS 7 - Networking Support”