判断端口通不通的几种方法「建议收藏」

判断端口通不通的几种方法「建议收藏」判断端口通不通的几种方法

大家好,又见面了,我是你们的朋友全栈君。

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)再连接存在的端口
[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是linux的标准配置并且最常用,可以用来判断端口吗?
用法: ssh -v -p port username@ip
-v 调试模式(会打印日志).
-p 指定端口
username可以随意
1)连接不存在端口
[root@localhost ~]# ssh 10.0.250.3 -p 80
ssh: connect to host 10.0.250.3 port 80: Connection refused
[root@localhost ~]# ssh 10.0.250.3 -p 80 -v
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.0.250.3 [10.0.250.3] port 80.
debug1: connect to address 10.0.250.3 port 80: Connection refused
ssh: connect to host 10.0.250.3 port 80: Connection refused

2)连接存在的端口
[root@localhost ~]# ssh ... -p
a
^]
^C
[root@localhost ~]# ssh ... -p -v
OpenSSH_.p, OpenSSL ..e-fips Feb
debug: Reading configuration data /etc/ssh/ssh_config
debug: Applying options for *
debug: Connecting to ... [...] port .
debug: Connection established.
debug: permanently_set_uid: /
debug: identity file /root/.ssh/identity type -
debug: identity file /root/.ssh/identity-cert type -
debug: identity file /root/.ssh/id_rsa type -
debug: identity file /root/.ssh/id_rsa-cert type -
debug: identity file /root/.ssh/id_dsa type -
debug: identity file /root/.ssh/id_dsa-cert type -
a
^C

不用-v选项也可以咯
3、使用wget判断
wget是linux下的下载工具,需要先安装.
用法: wget ip:port
1)连接不存在的端口
[root@localhost ~]# wget ...:
---- ::-- http://.../
Connecting to ...:... failed: Connection refused.

2)连接存在的端口
[root@localhost ~]# wget ...:
---- ::-- http://...:/
Connecting to ...:... connected.
HTTP request sent, awaiting response...
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/106107.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • select top 用法

    select top 用法access:selecttop(10)*fromtable1where1=1 db2:selectcolumnfromtablewhere1=1fetchfirst10rowsonly 取第三行到第5行的记录select*from(selectrow_number() over()asrowfromtable)ast

    2022年7月13日
  • 虚拟主机导入MySQL出现Unknown character set: ‘utf8mb4’

    虚拟主机导入MySQL出现Unknown character set: ‘utf8mb4’

    2021年10月7日
  • C语言如何计算数组的长度

    C语言如何计算数组的长度(1)借助sizeof()函数:#include<stdio.h>intmain(){ //定义一个整型数组,并进行初始化赋值9个数据:  intarr[]={1,2,3,4,5,6,7,8,9}; intlength=0; //计算数组中数据长度: //所有数据的字节数除以一个数据的字节数即为数据的个数:  length=sizeof(arr)/…

    2022年7月27日
  • VS Code 必备插件推荐「建议收藏」

    VS Code 必备插件推荐「建议收藏」插件说明备注AutoCloseTag自动添加HTML/XML关闭标签AutoRenameTag自动重命名配对的HTML/XML标签Beautify格式化代码BracketPairColorizer颜色识别匹配括号CodeRunner非常强大的一款插件…

    2022年5月6日
  • npn饱和截止放大怎么判断_二极管饱和状态

    npn饱和截止放大怎么判断_二极管饱和状态幼儿园水平理解三极管截止、放大和饱和状态!书上看不懂,听课听不懂的过来!绕不开的三极管结构以NPN为例,晶体三极管的结构,这是很多人不想看的,但是确实是非常重要的!不看结构是理解不了工作原理的!(这样记忆:N是negative,负,代表多子为电子;P是positive,正,代表多子为空穴)注意观察三极管的结构,有助于理解工作时的状态。两张图结合起来看,略作解释:1.图中空心为空穴带正…

    2022年9月10日
  • 机器学习之模型评估

    '没有测量,就没有科学'这是科学家门捷列夫的名言。在计算机科学特别是机器学习领域中,对模型的评估同样至关重要,只有选择与问题相匹配的评估方法,才能快速地发现模型选择或训练过程中出现的问

    2021年12月30日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号