在 Windows 7 中设置网络适配器指标优先级

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7785874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:49:53  来源:igfitidea点击:

Setting network adapter metric priority in Windows 7

windowsnetworkingwindows-7adapter

提问by Michael

I'm having an issue on Windows 7 - if I have my Ethernet cable plugged in, Windows will default to using my WiFi network adapter. I would prefer that Windows default to my Ethernet connection. In order to resolve this, I have to manually disconnect the WiFi adapter in Control Panel's "Networking and Sharing Center", and then it will recognize my Ethernet connection.

我在 Windows 7 上遇到问题 - 如果我插入了以太网电缆,Windows 将默认使用我的 WiFi 网络适配器。我希望 Windows 默认为我的以太网连接。为了解决这个问题,我必须在控制面板的“网络和共享中心”中手动断开 WiFi 适配器,然后它会识别我的以太网连接。

Another weird thing is when I look at Control Panel\Network and Internet\Network Connections, my "TAP-Win32 Adapter OAS" is always disconnected. My Ethernet adapter is only noticed when I have it plugged in; and only then it shows up as a new adapter called "Realtek PCIe GBE Family Controller".

另一个奇怪的事情是,当我查看Control Panel\Network 和 Internet\Network Connections 时,我的“TAP-Win32 Adapter OAS”总是断开连接。我的以太网适配器只有在插入时才会被注意到;然后它才显示为一个名为“Realtek PCIe GBE 系列控制器”的新适配器。

Note: Sorry I can't show screen captures because I'm one reputation point away from being able to show images.

注意:抱歉,我无法显示屏幕截图,因为我距离显示图像还有一个声誉点。

I followed the steps in the articles How to Change the Priority of Wired/Wireless Network Cards in Windowsand An explanation of the Automatic Metric feature for Internet Protocol routes

我按照文章如何更改 Windows 中有线/无线网卡的优先级Internet 协议路由的自动度量功能的说明中的步骤进行操作

Here are my current metrics (network adapter priority):

这是我当前的指标(网络适配器优先级):

C:\Users\Michael> netstat -rn    
===========================================================================
Interface List
10...1c c1 de 98 1b 88 ......Realtek PCIe GBE Family Controller
16...00 ff fa d7 9e 94 ......TAP-Win32 Adapter OAS
13...00 26 82 c8 41 a7 ......Broadcom 43224AG 802.11a/b/g/draft-n Wi-Fi Adapter
12...70 f3 95 79 4f ec ......Bluetooth Device (Personal Area Network)
24...00 50 56 c0 00 08 ......VMware Virtual Ethernet Adapter for VMnet8
 1...........................Software Loopback Interface 1
18...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
21...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
22...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #3
14...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface
17...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #4
20...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #5
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination  Netmask           Gateway     Interface     Metric
0.0.0.0              0.0.0.0           192.168.1.1 192.168.1.103     28
0.0.0.0              0.0.0.0           192.168.1.1 192.168.1.101     24
127.0.0.0            255.0.0.0         On-link         127.0.0.1    306
127.0.0.1            255.255.255.255   On-link         127.0.0.1    306
127.255.255.255      255.255.255.255   On-link         127.0.0.1    306
192.168.1.0          255.255.255.0     On-link     192.168.1.103    270
192.168.1.0          255.255.255.0     On-link     192.168.1.101    268
192.168.1.101        255.255.255.255   On-link     192.168.1.101    268
192.168.1.103        255.255.255.255   On-link     192.168.1.103    270
192.168.1.255        255.255.255.255   On-link     192.168.1.103    270
192.168.1.255        255.255.255.255   On-link     192.168.1.101    268
192.168.116.0        255.255.255.0     On-link     192.168.116.1    276
192.168.116.1        255.255.255.255   On-link     192.168.116.1    276
192.168.116.255      255.255.255.255   On-link     192.168.116.1    276
224.0.0.0            240.0.0.0         On-link         127.0.0.1    306
224.0.0.0            240.0.0.0         On-link     192.168.1.101    268
224.0.0.0            240.0.0.0         On-link     192.168.116.1    276
224.0.0.0            240.0.0.0         On-link     192.168.1.103    270
255.255.255.255      255.255.255.255   On-link         127.0.0.1    306
255.255.255.255      255.255.255.255   On-link     192.168.1.101    268
255.255.255.255      255.255.255.255   On-link     192.168.116.1    276
255.255.255.255      255.255.255.255   On-link     192.168.1.103    270
===========================================================================

Although the "Realtek PCIe GBE Family Controller" has the higher priority metric, Windows still uses the WiFi connection by default. So to be explicit, I followed the instructions from the article; I unchecked the "automatic metric" assignment, and set it manually; only for the following adapters (on TCP/IPv4):

尽管“Realtek PCIe GBE 系列控制器”具有更高的优先级指标,但 Windows 仍默认使用 WiFi 连接。因此,明确地说,我按照文章中的说明进行操作;我取消选中“自动指标”分配,并手动设置;仅适用于以下适配器(在 TCP/IPv4 上):

  • 10: TAP-Win32 Adapter OAS
  • 12: Realtek PCIe GBE Family Controller
  • 14: Broadcom 43224AG 802.11a/b/g/draft-n Wi-Fi Adapter
  • 16: Bluetooth Device (Personal Area Network)
  • 10:TAP-Win32 适配器 OAS
  • 12:Realtek PCIe GBE 系列控制器
  • 14:Broadcom 43224AG 802.11a/b/g/draft-n Wi-Fi 适配器
  • 16:蓝牙设备(个域网)

I then rebooted, and unfortunately, these settings were not picked up. Running the "netstat -rn" displays the same interface list priority as shown above, and again Windows used the WiFi adapter by default.

然后我重新启动,不幸的是,这些设置没有被选中。运行“netstat -rn”显示与上图相同的接口列表优先级,Windows 再次默认使用 WiFi 适配器。

If anyone has run into the same issues and resolved them, please let me know. The fact that Windows 7 does not prioritize an Ethernet connection over a WiFi connection baffles me, and its annoying to have to finagle around with it every time I boot up.

如果有人遇到同样的问题并解决了,请告诉我。Windows 7 没有优先考虑以太网连接而不是 WiFi 连接这一事实让我感到困惑,而且每次启动时都不得不摆弄它很烦人。

If you also understand the behavior for the two adapters "Realtek PCIe GBE Family Controller" and "TAP-Win32 Adapter OAS", that would be helpful as well.

如果您还了解“Realtek PCIe GBE 系列控制器”和“TAP-Win32 Adapter OAS”这两个适配器的行为,那也会有所帮助。

回答by JeremyK

Windows has two different settings in which priority is established. There is the metric value which you have already set in the adapter settings, and then there is the connection priority in the network connections settings.

Windows 有两种不同的设置,其中建立了优先级。在适配器设置中有你已经设置好的metric值,然后在网络连接设置中有连接优先级。

To change the priority of the connections:

要更改连接的优先级:

  • Open your Adapter Settings (Control Panel\Network and Internet\Network Connections)
  • Click Alt to pull up the menu bar
  • Select Advanced -> Advanced Settings
  • Change the order of the connections so that the connection you want to have priority is top on the list
  • 打开您的适配器设置(控制面板\网络和 Internet\网络连接)
  • 点击 Alt 拉起菜单栏
  • 选择高级 -> 高级设置
  • 更改连接的顺序,使您想要优先的连接在列表的顶部

回答by Matus

I had the same problem on Windows 7 64-bit Pro. I adjusted network adapters binding using Control panel but nothing changed. Also metrics where showing that Win should use Ethernet adapter as primary, but it didn't.

我在 Windows 7 64 位专业版上遇到了同样的问题。我使用控制面板调整了网络适配器绑定,但没有任何改变。还有指标显示 Win 应该使用以太网适配器作为主要的,但它没有。

Then a tried to uninstall Ethernet adapter driver and then install it again (without restart) and then I checked metrics for sure.

然后尝试卸载以太网适配器驱动程序,然后再次安装(无需重新启动),然后我确定检查了指标。

After this, Windows started prioritize Ethernet adapter.

在此之后,Windows 开始优先考虑以太网适配器。