zoukankan      html  css  js  c++  java
  • Linux测试端口是否连通的方法 -bash: telnet: 未找到命令

    telnet命令一般用来检测一个端口使用,新安装的linux系统或是Mac系统都可能是不支持telnet命令的,所以我们需要安装一下

    1.linux 安装:

    yum install telnet

    2.mac安装需要用到brew软件包管理器

    brew install telnet

    Linux几种常用测试端口连通的方法

    • 1 telnet方法
    • 2 wget方法
    • 3 ssh方法
    • 4 curl方法

    1 telnet

    #用法: telnet ip port
    #(1) telnet连接不存在的端口  
    telnet 1.1.1.1 8
        Trying 1.1.1.1...
        telnet: connect to address 1.1.1.1: Connection timed out
    #(2) telnet 链接存在端口
    telnet 1.1.1.1 8000
        Trying 1.1.1.1...
        Connected to 1.1.1.1.
        Escape character is '^]'.
        Connection closed by foreign host.

    2 wget

    #用法: wget ip:port
    #(1) 不存在端口
     wget 1.1.1.1:8  
        --2017-01-24 11:38:34-- http://1.1.1.1:8/   Connecting to 1.1.1.1:8... 
        failed: Connection timed out. Retrying.
    
    #(2) 存在端口
     wget 1.1.1.1:8000
        --2017-01-24 11:39:03--  http://1.1.1.1:8000/
        Connecting to 1.1.1.1:8000... connected.
        HTTP request sent, awaiting response... 200 OK

    3 ssh

    #用法: ssh -v -p port username@ip
    -v 调试模式(会打印日志).
    -p 指定端口
    这里没有给出测试,留给读者自己测试

    4 curl

    #用法: curl ip:port
    #(1) 不存在端口
        获取不到结果
    #(2) 存在端口
        curl  1.1.1.1:8000
        <!DOCTYPE html>
        <html>
            <head>xxx</head>
            <body>
                ......
            </body>
        </html>
  • 相关阅读:
    ubuntu下pip的安装和使用
    跨域总结
    本地存储小结
    SVN
    appium整理文档
    appium python andiroid自动化文档整理笔记
    Python 接口测试(二)
    Python 接口测试(一)
    Python 接口测试(四)
    Python 接口测试(三)
  • 原文地址:https://www.cnblogs.com/yoyowin/p/12145807.html
Copyright © 2011-2022 走看看