我的VPS运行在CentOS 7.2上,我通过firewall-cmd --zone=public --add-port=8006/tcp --permanent
打开了一个端口,并且已经输入了firewall-cmd --reload
命令,但是当我通过nmap检查端口时,nmap -p 8006 ip-addressxxx,它仍然显示它是关闭的。这里有一些信息可能会有所帮助:
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2017-04-07 02:06:50 EDT; 3 days ago
Docs: man:firewalld(1)
Main PID: 663 (firewalld)
CGroup: /system.slice/firewalld.service
└─663 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Apr 07 02:06:50 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 07 02:06:50 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Apr 10 02:03:42 localhost.localdomain firewalld[663]: ERROR: ALREADY_ENABLED: 80:tcp
Apr 10 02:03:49 localhost.localdomain firewalld[663]: ERROR: ALREADY_ENABLED: 8006:tcp
……
[root@localhost ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens3
sources:
services: dhcpv6-client ssh
ports: 8009/tcp 80/tcp 8080/tcp 8006/tcp
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules:
……
[root@localhost ~]# firewall-cmd --list-ports
8009/tcp 80/tcp 8080/tcp 8006/tcp
……
[root@localhost ~]# netstat -plunt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 992/sshd
tcp6 0 0 :::8009 :::* LISTEN 1027/java
tcp6 0 0 :::3306 :::* LISTEN 1383/mysqld
tcp6 0 0 :::80 :::* LISTEN 1027/java
tcp6 0 0 :::22 :::* LISTEN 992/sshd
tcp6 0 0 127.0.0.1:8006 :::* LISTEN 1027/java
2条答案
按热度按时间eoxn13cs1#
重温我的答案
在端口8006上侦听的进程只侦听环回接口
127.0.0.1
,它应该侦听0.0.0.0
。在你的进程列表0.0.0.0:22
中查看sshd进程,它工作正常。使用类似
netcat
的代码进行测试。这将在0.0.0.0
接口上打开8006
上的一个端口,由于您的防火墙规则,该端口对全世界开放在您的VPS上尝试:
nc -l 8006
然后再次用nmap扫描,您将看到端口已打开,前提是您的防火墙规则已就位。
您希望在进程列表中看到这个
tcp6 0 0 0.0.0.0:8006 :::* LISTEN 1027/java
而不是
tcp6 0 0 127.0.0.1:8006 :::* LISTEN 1027/java
knpiaxh12#
防火墙被禁用,“nmap localhost 9022”抛出一个输出端口被关闭。甚至尝试使用firewall-cmd手动打开端口,但没有运气。你能帮我打开港口吗?