如何测试端口的连通性?

通过命令行测试端口的连通性,可以快速帮助我们排查端口的问题,本文将介绍在macOS、Linux和Windows上如何测试端口的连通性?

Linux和Windows

在Linux和Windows下,我们就直接可以用 telnet 命令来测试端口是否畅通。具体用法:telnet 指定的IP或者域名端口号。

例如:

1
2
telnet 192.168.1.102 3306
telnet 127.0.0.1 8090

需要注意的是Windows需要在 启用或关闭Windows功能 中勾选 Telnet Client

macOS

1
2
3
4
5
6
7
8
9
10
11
$ nc -vz -w 2 192.168.100.57 1433
found 0 associations
found 1 connections:
1: flags=82<CONNECTED,PREFERRED>
outif en0
src 192.168.100.54 port 63398
dst 192.168.100.57 port 1433
rank info not available
TCP aux info available

Connection to 192.168.100.57 port 1433 [tcp/ms-sql-s] succeeded!

如何测试端口的连通性?

https://ganzhixiong.com/p/bc7e18e1/

Author

干志雄

Posted on

2021-06-07

Updated on

2021-06-07

Licensed under

Comments