Adjust network adapter priority in Windows
Posted on: 2026年10月27日 at 12:11
如果电脑中有很多虚拟网卡,一些程序获取局域网 IP 时只能获取到第一个,如果第一个虚拟网卡的 IP 不是你想要的,可以通过,列方法来调整网卡顺序,从而更改程序获取到的局域网 IP。
# 查看各网卡的 IfIndex 与当前跃点数(关注 InterfaceAlias / IfIndex / AddressFamily / InterfaceMetric)
Get-NetIPInterface | Format-Table -AutoSize
# 把索引为 11 的网卡跃点数设为 10(越小越优先)
Set-NetIPInterface -InterfaceIndex "11" -InterfaceMetric "10"
# 恢复自动跃点
Set-NetIPInterface -InterfaceIndex "11" -AutomaticMetric enabled