Centos nmap显示端口已关闭,即使我已打开它

Centos nmap显示端口已关闭,即使我已打开它,centos,firewall,nmap,Centos,Firewall,Nmap,我的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 -

我的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
。 .

。 .

。 .


重温我的答案

您在端口8006上侦听的进程仅在环回接口上侦听,
127.0.0.1
,它应该在
0.0.0
上侦听。请参阅进程列表中的sshd进程
0.0.0.0:22
它工作正常

使用类似于
netcat
的方法进行测试。这将在
0.0.0.0
界面上的
8006
上打开一个端口,由于您的防火墙规则,该端口向世界开放

在您的VPS上尝试:

nc-L8006

然后再次使用nmap扫描,您将看到该端口已打开,前提是您的防火墙规则已就位

您希望在流程列表中看到此内容

tcp6 0.0.0.0:8006::*收听1027/java

而不是

tcp6 0 0 127.0.0.1:8006::*收听1027/java

[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