目录
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).