如何测试端口通不通(四种方法)

投稿:mrr

一般情况下使用"telnet ip port"判断端口通不通.接下来通过本文给大家分享四种方法测试端口通不通,感兴趣的朋友一起学习吧

一般情况下使用"telnet ip port"判断端口通不通,其实测试方法不止这一种,还有很多种方法,下面小编给大家分享了几种方法,具体内容请往下看:

准备环境

启动一个web服务器,提供端口.

[wyq@localhost ~]$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...

用其它web服务器提供端口也一样,由于python比较方便,这里就用它

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

4、使用端口扫描工具

[root@localhost ~]# nmap ... -p
Starting Nmap . ( http://nmap.org ) at -- : CST
Nmap scan report for ...
Host is up (.s latency).
PORT STATE SERVICE
/tcp closed http
MAC Address: B:A::CF:FD:D (Unknown)
Nmap done: IP address ( host up) scanned in . seconds
[root@localhost ~]# nmap ... -p
Starting Nmap . ( http://nmap.org ) at -- : CST
Nmap scan report for ...
Host is up (.s latency).
PORT STATE SERVICE
/tcp open http-proxy
MAC Address: B:A::CF:FD:D (Unknown)
Nmap done: IP address ( host up) scanned in . seconds
[root@localhost ~]# nmap ...
Starting Nmap . ( http://nmap.org ) at -- : CST
Nmap scan report for ...
Host is up (.s latency).
Not shown: closed ports
PORT STATE SERVICE
/tcp open ssh
/tcp open rpcbind
/tcp open http-proxy
/tcp open unknown
MAC Address: B:A::CF:FD:D (Unknown)
Nmap done: IP address ( host up) scanned in . seconds

总结

提供端口服务,则使用了tcp协议,上面是以web服务器为例。如果服务器是更简单的tcp服务器,三个工具同样适用.

三个工具的共同点是:1.以tcp协议为基础;2.能访问指定端口. 遵循这两点可以找到很多工具.

一般在windows下使用telnet比较方便,linux下个人就比较喜欢用wget.

端口通不通 telnet wget ssh的更多相关文章

  1. 批量telnet端口通不通

    每读一行就运行一次telnet IP port #!/bin/bash port="22" cat *.txt | while read line do telnet ${line ...

  2. Linux服务器可以ping,但是telnet端口超时,网站wget超时,访问超时的解决办法

    最近无法通过SSH连接Linux服务器,访问该服务器上的HTTP服务也出现异常.可以ping,但是telnet端口超时,网站wget超时,访问超时. 最后排查是内核配置问题 原来是 net.ipv4. ...

  3. linux远程登录(Telnet、SSH)

    系统:RHEL 5.5 64位,使用CentOS的yum源并作更新处理 参考书目<Linux兵书>/电子工业出版社/刘丽霞,细节之处稍有变动. 一.Telnet(远程登录推荐SSH) 1. ...

  4. Telnet、SSH和VNC

    以下内容出自<Red Hat Linux服务器配置与应用>第17章:Telnet.SSH和VNC服务的配置与应用.俗话说:“前人栽树,后人乘凉”.我懒得再照书本打一遍了,就从这里拷贝了一份 ...

  5. Telnet、SSH和VNC 区别

    Telnet Telnet是进行远程登录的标准协议,它是当今Internet上应用最广泛的协议之一.它把用户正在使用的终 端或计算机变成网络某一远程主机的仿真终端,使得用户可以方便地使用远程主机上的软 ...

  6. Telnet和SSH

    1. 协议用途 Telnet和SSH用于远程访问服务器的的两大常用协议.利用它们,我们可以管理并监控生产服务器和企业服务器,更新服务器内核,安装最新的软件包和补丁,能够远程登录服务器,开展软件开发.测 ...

  7. openstack 主机无法ping通instance,无法ssh到instance

    https://docs.openstack.org/zh_CN/user-guide/cli-nova-configure-access-security-for-instances.html 好不 ...

  8. 教你如何暴力破解-telnet ftp ssh mysql mssql vnc 等

    大家应该都知道暴力破解的原理,但却不知道遇见telnet和ftp等服务和数据库如何破解,今天小R就教大家如何利用一个工具就能对其破解. 今天要给大家介绍的工具是:hydra(中文名:九头蛇) 这个名听 ...

  9. Shell命令-网络操作之基础之telnet、ssh

    文件及内容处理 - telnet.ssh 1. telnet:使用TELNET协议远程登录 telnet命令的功能说明 telnet 命令用于远端登入.执行 telnet 指令开启终端机阶段作业,并登 ...

随机推荐

  1. TCP/IP,三次握手四次挥手,TCP/UDP , HTTP/HTTPS

    internet:通用名词,由多个计算机网络组成的网络,网络间的通信协议是任意的 Internet:专用名词,当前全球最大的开放计算机网络,采用TCP/IP协议族作为通信的规则.www万维网是广泛应用 ...

  2. kibana 删除document或者type

    // 删除某个document DELETE /索引名称/type名称/document编号(id) // 删除整个type PUT 索引名称/type名称/_delete_by_query?conf ...

  3. mybatis注解中写SQL语句

    参考: https://blog.csdn.net/gebitan505/article/details/54929287/https://blog.csdn.net/KingBoyWorld/art ...

  4. [Codeforces #608 div2]1271C Shawarma Tent

    Description The map of the capital of Berland can be viewed on the infinite coordinate plane. Each p ...

  5. Day2-K-Red and Black-HDU1312

    There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A ...

  6. 尝试使用 Visual Studio Online (Cloud IDE)

    这里的 Visual Studio Online 不是 Azure DevOps ,他们虽然是相同的名称,却是不同的域名 https://online.visualstudio.com/ ,今天我们就 ...

  7. qrcode在手机上不显示的问题

    可以试试以下解决方案: 1.修改qrcode.min.js:里的function n()红线区域替换成这个 , 原因是这样子才能支持安卓机显示.

  8. java中二进制反码补码的理解

    7句真言 1,二进制最高位是符号位 0正数 1负数 2,正数的原码,反码,补码都一样 3负数的原码反码 补码 (符号位不变,其他的位数取反 0->1 1->0) 4 0的反码补码都是0 5 ...

  9. git+jenkins jar包代码的发布加新建项目

    1.本地仓库  java开发 把代码上传上来 ,问一下他要上传到的主机ip , 分支 2.本地 , 设置-->仓库 更新数据,让他同步到南阳gitlab, 若没有这个项目,需要创建相同名字的项目 ...

  10. node批量修改文件名称

    let fs = require('fs');//引用文件系统模块 let PATH = `./app_zijietiaodong/`;//当前文件夹 let ext = { readFileList ...