Linux检测远程端口是否打开的六种方法

                                         Linux检测远程端口是否打开的六种方法

服务器环境:

[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.


方法五:Tcping 【yum  -y install  tcping

#端口通
[root@java-test-server ~]# tcping  88.88.88.88   80
88.88.88.88  port 80 open.


#端口不通
[root@java-test-server ~]# tcping  88.88.88.88   22  #无响应

方法六:Wget命令 【yum  -y install  wget

#端口通
[root@goliveplus_test ~]# wget --delete-after -t1 -T1 "http://88.88.88.88:80"

--2020-08-08 14:59:49--  http://88.88.88.88/
正在连接 88.88.88.88:22... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:3196 (3.1K) [text/html]
正在保存至: “index.html.1”

100%[========================================================================================================================================>] 3,196       --.-K/s 用时 0s

2020-08-08 14:59:49 (247 MB/s) - 已保存 “index.html.1” [3196/3196])

正在删除 index.html.1。


#端口不通
[root@goliveplus_test ~]# wget --delete-after -t1 -T1 "http://88.88.88.88:22"

--2020-08-08 14:59:33--  http://88.88.88.88:22/
正在连接 88.88.88.88:22... 失败:连接超时。
放弃操作。

 

  • 7
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值