linux 测试机器端口连通性方法

转至:https://blog.csdn.net/z1134145881/article/details/54706711

几种常用方法

下面一一介绍:

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

 

posted @   study_goup  阅读(364)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示