在 Centos 8 上打开端口
Open port on Centos 8
我正在尝试 运行 在 centos8 上的本地主机上的端口 61009 上的服务,但连接被拒绝。我尝试使用 firewall-cmd 命令打开端口。 firewall-cmd --list-all 的输出如下所示。
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: cockpit dhcpv6-client ssh
ports: 61008-61010/tcp 61022-61024/tcp 61009/tcp
protocols:
masquerade: yes
forward-ports:
source-ports:
icmp-blocks:
rich rules:
我的OS详情如下
NAME=“CentOS Linux”
VERSION=“8 (Core)”
ID=“centos”
ID_LIKE=“rhel fedora”
VERSION_ID=“8”
PLATFORM_ID=“platform:el8”
PRETTY_NAME=“CentOS Linux 8 (Core)”
ANSI_COLOR=“0;31”
CPE_NAME=“cpe:/o:centos:centos:8”
HOME_URL=“https://www.centos.org/”
BUG_REPORT_URL=“https://bugs.centos.org/”
CENTOS_MANTISBT_PROJECT=“CentOS-8”
CENTOS_MANTISBT_PROJECT_VERSION=“8”
telnet 本地主机 61009
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
如何在 centos8 上打开端口?
检查端口状态
netstat -na | grep 61009
在 iptables 中检查端口状态
iptables-save | grep 61009
添加端口
# vi /etc/services
service-name port/protocol [aliases ...] [# comment]
在防火墙中打开端口
# firewall-cmd --zone=public --add-port=61009/tcp --permanent
success
# firewall-cmd --reload
success
# iptables-save | grep 61009
-A IN_public_allow -p tcp -m tcp --dport 61009 -m conntrack --ctstate NEW -j ACCEPT
检查添加的端口状态
lsof -i -P |grep http
netstat -na |grep 61009
我正在尝试 运行 在 centos8 上的本地主机上的端口 61009 上的服务,但连接被拒绝。我尝试使用 firewall-cmd 命令打开端口。 firewall-cmd --list-all 的输出如下所示。
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: cockpit dhcpv6-client ssh
ports: 61008-61010/tcp 61022-61024/tcp 61009/tcp
protocols:
masquerade: yes
forward-ports:
source-ports:
icmp-blocks:
rich rules:
我的OS详情如下
NAME=“CentOS Linux”
VERSION=“8 (Core)”
ID=“centos”
ID_LIKE=“rhel fedora”
VERSION_ID=“8”
PLATFORM_ID=“platform:el8”
PRETTY_NAME=“CentOS Linux 8 (Core)”
ANSI_COLOR=“0;31”
CPE_NAME=“cpe:/o:centos:centos:8”
HOME_URL=“https://www.centos.org/”
BUG_REPORT_URL=“https://bugs.centos.org/”
CENTOS_MANTISBT_PROJECT=“CentOS-8”
CENTOS_MANTISBT_PROJECT_VERSION=“8”
telnet 本地主机 61009
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
如何在 centos8 上打开端口?
检查端口状态
netstat -na | grep 61009
在 iptables 中检查端口状态
iptables-save | grep 61009
添加端口
# vi /etc/services service-name port/protocol [aliases ...] [# comment]
在防火墙中打开端口
# firewall-cmd --zone=public --add-port=61009/tcp --permanent success # firewall-cmd --reload success # iptables-save | grep 61009 -A IN_public_allow -p tcp -m tcp --dport 61009 -m conntrack --ctstate NEW -j ACCEPT
检查添加的端口状态
lsof -i -P |grep http netstat -na |grep 61009