目录
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, awaiting response... 200 No headers, 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).
本文介绍了三种检查网络端口是否开放的方法:使用telnet、ssh及wget工具进行连接测试。涵盖不同场景下的具体操作步骤,如telnet连接监听与未监听端口的区别、ssh连接时的调试模式使用等。
1247

被折叠的 条评论
为什么被折叠?



