设置网卡优先级(接口跃点数)
让电脑同时连着有线和 Wi-Fi 时优先走其中一个网络。
运行 Set-NetIPInterface -InterfaceAlias "Ethernet" -InterfaceMetric 10,把 Wi-Fi 设成较大的 50 即可优先有线。
01命令
命令
$ Set-NetIPInterface -InterfaceAlias "Ethernet" -InterfaceMetric 10
Set-NetIPInterface -InterfaceAlias "Wi-Fi" -InterfaceMetric 5002作用说明
电脑同时连接两块网卡时,Windows 按接口跃点数(metric)选择路由,数值越小优先级越高。把有线设为 10、Wi-Fi 设为 50,流量就会优先走有线,Wi-Fi 保持连接作为备用。把参数改回 Automatic 可恢复系统自动计算的默认值。
03风险
!注意: 手动固定跃点数后不会再随网络变化自动调整——之后如果网络异常,用 -InterfaceMetric Automatic 恢复。
04撤销
撤销
$ Set-NetIPInterface -InterfaceAlias "Ethernet" -InterfaceMetric Automatic05来源
- Set-NetIPInterface依据: Documents the InterfaceAlias, InterfaceMetric and Automatic parameters for setting adapter routing priority.
最后验证: 2026-09-18 · 分类: 网络
06相关方案
在 Windows 用 Test-NetConnection 测试 TCP 端口连通性
Windows 自带的 PowerShell 一行命令,直接回答“这个网络的 5432/3389/443 端口通不通”——不再需要安装 telnet 客户端。
用 Get-NetTCPConnection 列出监听端口和占用进程
netstat 的 PowerShell 原生替代品:按状态、端口、进程过滤连接,输出可直接管道处理而不用解析文本。
在 PowerShell 中用 Resolve-DnsName 查询 DNS 记录
nslookup 的现代化、可脚本化替代:查询指定记录类型、指定 DNS 服务器,并把结果当对象处理。