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

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

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

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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 博途v15定时器设置_博图界面怎么修改定时器时间

    博途v15定时器设置_博图界面怎么修改定时器时间FUNCTION_BLOCKFB8VAR_INPUTTakt:BOOL;//Takt-Signalinput,suchasM0.0toM0.7Start:BOOL;Reset:BOOL;END_VARVARTakt_old:BOOL;BitNr:INT;currTime:…

    2022年9月1日
    1
  • SQL SERVER实例解析

    什么是SQLSERVER实例SQLSERVER实例的概念和“类与对象”的概念很相似。可以把SQLSERVER的安装程序看做是一个类,安装过程则是创建对象的过程,创建出来的对象称为“SQLSE

    2021年12月22日
    54
  • springboot+idea热部署(自动刷新)

    springboot+idea热部署(自动刷新)近来在使用idea做springboot的项目,但是发现每次修改之后我都需要重新将项目关闭再开启,这样比较繁琐,发现通过热部署的方式让我们可以一边修改我们的项目,然后在页面中直接通过刷新展示出来spring为开发者提供了一个名为spring-boot-devtools的模块来使SpringBoot应用支持热部署,提高开发者的开发效率,无需手动重启SpringBoot应用。devtool…

    2022年6月26日
    48
  • groupadd r mysql_useradd 和groupadd

    groupadd r mysql_useradd 和groupadd1.作用useradd命令用来建立用户帐号和创建用户的起始目录,使用权限是终极用户。2.格式useradd[-dhome][-sshell][-ccomment][-m[-ktemplate]][-finactive][-eexpire][-ppasswd][-r]name3.主要参数-c:加上备注文字,备注文字保存在passwd的备注栏中。-d:指定用户登入时…

    2025年8月3日
    4
  • 红黑树和平衡二叉树区别[通俗易懂]

    红黑树和平衡二叉树区别[通俗易懂]红黑树和平衡二叉树区别如下:1、红黑树放弃了追求完全平衡,追求大致平衡,在与平衡二叉树的时间复杂度相差不大的情况下,保证每次插入最多只需要三次旋转就能达到平衡,实现起来也更为简单。2、平衡二叉树追求绝对平衡,条件比较苛刻,实现起来比较麻烦,每次插入新节点之后需要旋转的次数不能预知。…

    2022年10月20日
    1
  • CultureInfo 類別

    CultureInfo 類別CultureInfo類別.NETFramework2.0其他版本.NETFramework4.5.NETFramework4.NETFramework3.5Silverlight5人當中有2人評分為有幫助-為這個主題評分提供特定文化特性(Culture)的相關資訊,如文化特性名稱、書寫系…

    2022年6月19日
    91

发表回复

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

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