• 【Linux】测试ip:port端口是否连通即可达性测试


    【Linux】测试ip:port端口是否连通即可达性测试
    0、背景
    1、telnet可达性测试
    2、curl可达性测试
    3、wget可达性测试

    0、背景
    在视觉项目开发调试的过程中经常需要判定IPC是否可达,在做服务的时候也需要判定服务器是否可达。
    本博客介绍3种常用的工具(telnet、curl、wget)进行可达性测试。

    1、telnet可达性测试

      telnet ip port
    
    • 1
    • 例如:telnet 127.0.0.1 8080

    如果telnet 连接ip port存在,则会出现如下示例:

    root@s3d-wandev:/home/mysql/mysql_data# telnet 127.0.0.1 8888
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    
    • 1
    • 2
    • 3
    • 4

    如果telnet连接ip port不存在,则会出现如下示例:

    root@s3d-wandev:/home/mysql/mysql_data# telnet 127.0.0.1 8882
    Trying 127.0.0.1...
    telnet: Unable to connect to remote host: Connection refused
    
    • 1
    • 2
    • 3

    2、curl可达性测试

    curl ip:port
    
    • 1
    • 例如:curl 127.0.0.1:8080
      如果curl连接ip:port存在,则会出现如下示例:
    root@s3d-wandev:/home/mysql/mysql_data# curl 127.0.0.1:8888
    <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;
    
    • 1
    • 2

    如果curl连接ip:port不存在,则会出现如下示例:

    root@s3d-wandev:/home/mysql/mysql_data# curl 127.0.0.1:8882
    curl: (7) Failed to connect to 127.0.0.1 port 8882: Connection refused
    
    • 1
    • 2

    3、wget可达性测试

    wget ip:port
    
    • 1
    • 例如:wget 127.0.0.1:8080

    如果wget 连接ip:port存在,则会出现如下示例:

    root@s3d-wandev:/# wget 127.0.0.1:8888
    --2022-12-05 15:12:05--  http://127.0.0.1:8888/
    Connecting to 127.0.0.1:8888... connected.
    HTTP request sent, awaiting response... 404 
    2022-12-05 15:12:05 ERROR 404: (no description).
    
    • 1
    • 2
    • 3
    • 4
    • 5

    如果wget 连接ip:port不存在,则会出现如下示例:

    root@s3d-wandev:/# wget 127.0.0.1:8080
    --2022-12-05 15:12:00--  http://127.0.0.1:8080/
    Connecting to 127.0.0.1:8080... failed: Connection refused.
    
    • 1
    • 2
    • 3
  • 相关阅读:
    KVM API docs
    Linux安装RocketMQ
    企业私有云架构的安全设计和安全运营
    当下的力量(解读版)
    Vuex使用方式及异步问题处理
    有哪些不起眼却赚钱的行业?
    发电行业中的5G组网模式分析
    Active Directory用户登录报告
    docker离线搭建仓库
    Rocky9 上安装 redis-dump 和redis-load 命令
  • 原文地址:https://blog.csdn.net/MortShi/article/details/128182234