How do I open a port number in CentOS7
My linode is centos 7 with firewalld as the firewall.
I have set the port 2223 open, but can't connect outside.
Please give me some advice, thank you .
There are two things that could be at play here:
1. Ensure the firewall rules are in place
For Firewalld, the way to check would be the following:
First get the active zones. It will most likely be
public, but there may be others.
$ firewall-cmd --get-active-zones
Then, once you have the active zones you can check to make sure the firewall is opened where you expect it to be. I'll use
public in the example, but as mentioned, use whatever the active zones are from above.
$ sudo firewall-cmd --zone=public --list-all
You're hoping to see something like the following, with
2223/tcp listed in the
$ sudo firewall-cmd --zone=public --list-all public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: ssh dhcpv6-client ports: 2223/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
If it is not there, but you are sure that you added the rule, you may need to reload your firewall rules.
$ sudo firewall-cmd --reload
For more details, there are a few common scenarios in Linode's FirewallD doc.
2. Ensure the service is listening
If all the results from above show the port being open, it's possible that it is, but there is nothing listening. The output of the following will show what could be listening on that port.
$ sudo ss -tulpn
Or look for only services that include 2223 in the output.
$ sudo ss -tulpn | grep 2223
Today I can access this port, but i do not do anything on this linode .
i am confused now…
Thank you for replay.
sudo firewall-cmd --zone=public --list-all
sudo ss -tulpn
Netid State Recv-Q Send-Q Local Address:Port Peer Address:P
tcp LISTEN 0 128 *:2223 *:* )
tcp LISTEN 0 128 :::2223 :::* )