图例:
PS PowerShell 专属命令
CMD CMD 专属命令
通用 CMD 和 PowerShell 都可使用
PowerShell 命令
网络诊断
测试网络连通性 PowerShell
Test-NetConnection www.baidu.com -Count 4
测试指定端口 PowerShell
Test-NetConnection -ComputerName www.baidu.com -Port 80
DNS查询 PowerShell
Resolve-DnsName www.baidu.com
查看路由表 PowerShell
Get-NetRoute
查看网卡信息 PowerShell
Get-NetAdapter
IP地址
查看IP地址 PowerShell
Get-NetIPAddress
查看IP配置 PowerShell
Get-NetIPConfiguration
查看MAC地址 PowerShell
Get-NetAdapter | Select-Object Name, MacAddress
查看公网IP PowerShell
Invoke-RestMethod ifconfig.me
端口与连接
查看TCP连接 PowerShell
Get-NetTCPConnection
查看端口对应进程 PowerShell
Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess
测试端口连通 PowerShell
Test-NetConnection -ComputerName 192.168.1.1 -Port 80
下载
下载文件 PowerShell
Invoke-WebRequest -Uri "https://example.com/file.zip" -OutFile "file.zip"
获取API数据 PowerShell
Invoke-RestMethod -Uri "https://api.example.com/data" | ConvertTo-Json
CMD / 通用命令
网络诊断
ping 测试网络连通性 通用
ping www.baidu.com
ping 指定次数 通用
ping -n 4 www.baidu.com
ping 指定包大小 通用
ping -l 1024 www.baidu.com
tracert 路由跟踪 通用
tracert www.baidu.com
pathping 路由跟踪(带丢包统计) 通用
pathping www.baidu.com
nslookup DNS查询 通用
nslookup www.baidu.com
IP地址
查看本机IP 通用
ipconfig
查看IP详细 通用
ipconfig /all
查看ARP表 通用
arp -a
查看MAC地址 通用
getmac
释放IP地址 通用
ipconfig /release
重新获取IP 通用
ipconfig /renew
刷新DNS缓存 通用
ipconfig /flushdns
端口与连接
netstat 查看所有连接 通用
netstat -ano
查看指定端口占用 CMD
netstat -ano | findstr :8080
查看端口对应进程 CMD
tasklist | findstr <PID>
telnet 测试端口 CMD
telnet 192.168.1.1 80
下载
curl 下载文件 通用
curl -O https://example.com/file.zip
wget 下载文件 CMD
wget https://example.com/file.zip