1、telnet命令

格式: telnet ip 端口号


[root@centos7-127 ~]# telnet 192.168.87.128 22
Trying 192.168.87.128...
Connected to 192.168.87.128.  # 表示端口已经开放
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4

[root@centos7-127 ~]# telnet 192.168.87.128 8008
Trying 192.168.87.128...
telnet: connect to address 192.168.87.128: Connection refused # 表示端口未开放

2、nmap命令

格式: nmap ip -p 端口号


Starting Nmap 6.40 ( http://nmap.org ) at 2019-09-19 10:34 CST
Nmap scan report for centos7-128.cn (192.168.87.128)
Host is up (0.00028s latency). # 主机可通
PORT   STATE SERVICE
80/tcp open  http # 端口开放
MAC Address: 00:0C:29:0C:AE:01 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.08 seconds
[root@centos7-127 ~]# nmap 192.168.87.128 -p 8080

Starting Nmap 6.40 ( http://nmap.org ) at 2019-09-19 10:34 CST
Nmap scan report for centos7-128.cn (192.168.87.128)
Host is up (0.00035s latency). # 主机可通
PORT     STATE  SERVICE
8080/tcp closed http-proxy # 端口关闭
MAC Address: 00:0C:29:0C:AE:01 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

3、通过nc命令检查

命令格式:nc -v ip 端口


[root@centos7-127 ~]# nc -v 192.168.87.128 80
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.87.128:80. # 端口开放
^C
[root@centos7-127 ~]# nc -v 192.168.87.128 8080
Ncat: Version 7.50 ( https://nmap.org/ncat ) # 端口关闭
Ncat: Connection refused.
01-14 11:27