微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

测试 远程端口 是否处于监听状态

目录

1、使用telnet判断

1)telnet连接 未监听的端口

2)telnet连接 监听中的端口

2、使用ssh判断

1)ssh连接 未监听的端口

2)ssh连接 监听中的端口 

3、使用wget判断

1)wget连接 未监听的端口

2)wget连接 监听中的端口


1、使用telnet判断

telnet是windows标准服务,可以直接用;如果是linux机器,需要安装telnet.

用法: telnet ip port

1)telnet连接 未监听的端口

[root@localhost ~] # telnet 10.0.250.3 80
Trying 10.0.250.3...
telnet: connect to address 10.0.250.3: Connection refused #直接提示连接被拒绝

2)telnet连接 监听中的端口

[root@localhost ~] # telnet localhost 22
Trying ::1...
Connected to localhost. #看到Connected就连接成功了
Escape character is '^]' .
SSH-2.0-OpenSSH_5.3
a
Protocol mismatch.
Connection closed by foreign host

2、使用ssh判断

用法: ssh -v -p port username@ip

-v 调试模式(会打印日志).

-p 指定端口

username可以随意

1)ssh连接 未监听的端口

[root@localhost ~]# ssh 192.168.1.20 -p 7412
ssh: connect to host 192.168.1.20 port 7412: Connection refused

2)ssh连接 监听中的端口 

当监听端口不是ssh服务端口时

[root@localhost ~]# ssh 192.168.1.20 -p 9999
ssh_exchange_identification: Connection closed by remote host

当监听端口是ssh服务端口时:

[root@localhost ~]# ssh localhost -p 22
Warning: Permanently added 'localhost' (ECDSA) to the list of kNown hosts.
root@localhost's password:

会出现输入密码提示

3、使用wget判断

wget是linux下的下载工具,需要先安装.

用法: wget ip:port

1)wget连接 未监听的端口

[root@localhost test]# wget 10.0.250.3:80
--2022-03-27 17:43:41--  http://10.0.250.3/
Connecting to 10.0.250.3:80... ^C

一直卡在连接中

2)wget连接 监听中的端口

[root@localhost test]# wget localhost:22
--2022-03-27 17:42:48--  http://localhost:22/
Resolving localhost (localhost)... 127.0.0.1,::1
Connecting to localhost (localhost)|127.0.0.1|:22... connected.
HTTP request sent,awaiting response... 200 No headers,assuming HTTP/0.9
Length: unspecified
Saving to: ‘index.html.2’

    [ <=>                                                                                                                                                ] 40          --.-K/s   in 0s

2022-03-27 17:42:48 (3.62 MB/s) - Read error at byte 40 (Connection reset by peer).retrying.

--2022-03-27 17:42:49--  (try: 2)  http://localhost:22/
Connecting to localhost (localhost)|127.0.0.1|:22... connected.
HTTP request sent,assuming HTTP/0.9
Length: unspecified
Saving to: ‘index.html.2’

    [ <=>                                                                                                                                                ] 0           --.-K/s   in 0s


Cannot write to ‘index.html.2’ (Connection reset by peer).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐