Windows PowerShell 使用 Test-NetConnection 测试网络连接
PowerShell Windows 大约 2141 字Test-NetConnection
可简写为TNC
、tnc
。
PS C:\> Get-Alias tnc
CommandType Name Version Source
----------- ---- ------- ------
Alias TNC -> Test-NetConnection 1.0.0.0 NetTCPIP
测试网络
tnc
默认使用ping
连接internetbeacon.msedge.net
。
tnc
输出
PS C:\> tnc
ComputerName : internetbeacon.msedge.net
RemoteAddress : 13.107.4.52
InterfaceAlias : WLAN
SourceAddress : 192.168.1.100
PingSucceeded : True
PingReplyDetails (RTT) : 42 ms
测试端口
等同于telnet www.baidu.com 443
、nc -vz www.baidu.com 443
等端口测试命令。
Test-NetConnection -ComputerName www.baidu.com -Port 443
输出
PS C:\> Test-NetConnection -ComputerName www.baidu.com -Port 443
ComputerName : www.baidu.com
RemoteAddress : 180.101.49.11
RemotePort : 443
InterfaceAlias : WLAN
SourceAddress : 192.168.1.100
TcpTestSucceeded : True
测试本地端口(未开启8080
端口)
Test-NetConnection -ComputerName 127.0.0.1 -Port 8080
输出
PS C:\> Test-NetConnection -ComputerName 127.0.0.1 -Port 8080
警告: TCP connect to (127.0.0.1 : 8080) failed
ComputerName : 127.0.0.1
RemoteAddress : 127.0.0.1
RemotePort : 8080
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : 127.0.0.1
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False
简写
tnc www.baidu.com -p 443
输出详细信息
tnc www.baidu.com -p 443 -InformationLevel "Detailed"
输出
PS C:\Users\thunk> tnc www.baidu.com -p 443 -InformationLevel "Detailed"
ComputerName : www.baidu.com
RemoteAddress : 180.101.49.12
RemotePort : 443
NameResolutionResults : 180.101.49.12
180.101.49.11
MatchingIPsecRules :
NetworkIsolationContext : Internet
IsAdmin : False
InterfaceAlias : WLAN
SourceAddress : 192.168.1.100
NetRoute (NextHop) : 192.168.1.1
TcpTestSucceeded : True
更多帮助
Get-Help tnc
或者
man tnc
参考
https://docs.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection
阅读 2169 · 发布于 2022-06-27
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
IDEA 配置 Docker 可视化界面阅读 824
-
Linux xxx is not in the sudoers file.This incident will be reported阅读 2349
-
Java SPI 机制阅读 779
-
软考-系统架构设计师:主存-编址阅读 2834
-
Spring AOP 原理阅读 1186
-
Docker 搭建私有仓库 Registry阅读 902
-
Android 底部控件不受输入法影响被顶到上方阅读 1659
-
面试题:HTTP2.0 与 HTTP1.1 的区别阅读 3415
-
Docker 部署 OpenLDAP阅读 499
-
Rust Cargo update crate.io index 时无响应阅读 95