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

目录

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, 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).

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值