[root@java-test-server ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
方法一:Telnet命令【yum -y install telnet】
#端口通显示如下(实验IP为自定义IP)
[root@java-test-server ~]# telnet 88.88.88.88 80
Trying 202.122.38.84...
Connected to 202.122.38.84.
Escape character is '^]'.
#端口不通
[root@java-test-server ~]# telnet 88.88.88.88 22
Trying 202.122.38.84...
方法二:Nmap命令【yum -y install nmap】
#端口通
[root@java-test-server ~]# nmap 88.88.88.88 -p 80
Starting Nmap 6.40 ( http://nmap.org ) at 2020-08-08 13:56 CST
Nmap scan report for test.test.test.cn (88.88.88.88)
Host is up (0.026s latency).
PORT STATE SERVICE
80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 0.19 seconds
#端口不通
[root@java-test-server ~]# nmap 88.88.88.88 -p 22
Starting Nmap 6.40 ( http://nmap.org ) at 2020-08-08 13:58 CST
Nmap scan report for test.test.test.cn (88.88.88.88)
Host is up (0.027s latency).
PORT STATE SERVICE
22/tcp filtered ssh
Nmap done: 1 IP address (1 host up) scanned in 0.44 seconds
方法三:Nc命令 【yum -y install nmap-ncat】
#端口通
[root@java-test-server ~]# nc -zvw10 88.88.88.88 80
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 202.122.38.84:80.
Ncat: 0 bytes sent, 0 bytes received in 0.04 seconds.
#端口不通
[root@java-test-server ~]# nc -zvw10 88.88.88.88 22
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection timed out.
方法四:SSH命令【系统自带,无需安装】
#端口通
[root@java-test-server ~]# ssh -v 88.88.88.88 -p 80
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 88.88.88.88 [88.88.88.88] port 80.
debug1: Connection established. #建立连接
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: Connection closed by remote host
#端口不通
[root@java-test-server ~]# ssh -v 88.88.88.88 -p 22
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 88.88.88.88 [88.88.88.88] port 22.