Linux下检测某个ip端口的连通状态

举个例子,要测试的 ip+port: 192.168.0.100:8080

  1. 使用 telnet 命令

    telnet 192.168.0.100 8080

    连通成功:

    1
    2
    3
    4
    Trying 192.168.0.100...
    Connected to 192.168.0.100.
    Escape character is '^]'.
    Connection closed by foreign host.

    连通失败:

    1
    2
    rying 192.168.0.100...
    telnet: Unable to connect to remote host: Connection refused
  2. 使用 nc 命令

    nc -zvw3 192.168.0.100 8080

    参数说明:

    1. -z: 仅扫描侦听, 不会发送数据。

    2. -v: 输出详细信息。

    3. -w3: 允许超时3秒~

      连通成功:

      1
      Connection to 192.168.0.100 8080 port [tcp/http] succeeded!

      连通失败:

      1
      nc: connect to 192.168.0.100 port 8080 (tcp) failed: Connection refused
  3. 使用 nmap 命令

    nmap 192.168.0.100 -p 8080

    连通成功:

    1
    2
    3
    4
    5
    6
    7
    8
    Starting Nmap 7.80 ( https://nmap.org ) at 2021-01-21 21:30 CST
    Nmap scan report for 192.168.0.100
    Host is up (0.00049s latency).

    PORT STATE SERVICE
    8080/tcp open http

    Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

    连通失败:

    1
    2
    3
    4
    5
    6
    7
    8
    Starting Nmap 7.80 ( https://nmap.org ) at 2021-01-21 21:30 CST
    Nmap scan report for 192.168.0.100
    Host is up (0.00029s latency).

    PORT STATE SERVICE
    8080/tcp closed unknown

    Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds

欢迎访问 spaceack.com

文章作者: Spaceack
文章链接: http://spaceack.com/2021/01/21/2021-01-21-Linux%E4%B8%8B%E6%A3%80%E6%B5%8B%E6%9F%90%E4%B8%AAip%E7%AB%AF%E5%8F%A3%E7%9A%84%E8%BF%9E%E9%80%9A%E7%8A%B6%E6%80%81/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 编程之舞
支付宝打赏
微信打赏