Windows 中在多网卡系统中指定网卡的优先使用顺序
2011-07-05 21:51
579 查看
看见以下这个帖子,为了有线LAN连接和无线WLAN连接搞的很烦,感觉回答者也不得要领。总结整理了一下,记录在这里。
http://social.microsoft.com/Forums/zh-CN/window7betacn/thread/0e95dc43-dac9-4f0c-ba67-88e381dc3f9f
多网卡系统中,尤其在办公室中,确实是不应该使用无线连接,应该自动优先使用有线连接来保证客户端和网络两方面的性能。但是这要在客户端设置。 MS 有一个KB详细介绍了设置方法: http://support.microsoft.com/kb/894564
基本原理就是 给每个绑定了 TCP/IP的网络连接指定不同的权重,这样在Windows的路由表中,每个网卡对应的路由就有不同的权重,Windows就会优先使用低权重的路由(网络连接)了。具体操作就是 WMI 的 Win32_NetworkAdapterConfiguration 类有一个属性 IPConnectionMetric ,给无线网络连接实例的这个属性赋予 较高的权重值即可。
http://msdn.microsoft.com/en-us/library/aa394217(v=vs.85).aspx MSDN 中描述的很详细,重要部分摘录如下
Cost of using the configured routes for the IP bound adapter and is the weighted value for those routes in the IP routing table. If there are multiple routes to a destination in the IP routing table, the route with the lowest metric is used. The default value is 1.
Windows 2000: This property is not available. --------- 注意 Win 2000上不能用,没这个属性。
有通过注册表的方法,和通过WMI 脚本两种方法,KB中都描述的很详细,建议有兴趣的朋友自行研究测试。注册表方法比较繁琐,还是脚本方法比较适合企业环境,所以我摘录如下
http://social.microsoft.com/Forums/zh-CN/window7betacn/thread/0e95dc43-dac9-4f0c-ba67-88e381dc3f9f
多网卡系统中,尤其在办公室中,确实是不应该使用无线连接,应该自动优先使用有线连接来保证客户端和网络两方面的性能。但是这要在客户端设置。 MS 有一个KB详细介绍了设置方法: http://support.microsoft.com/kb/894564
基本原理就是 给每个绑定了 TCP/IP的网络连接指定不同的权重,这样在Windows的路由表中,每个网卡对应的路由就有不同的权重,Windows就会优先使用低权重的路由(网络连接)了。具体操作就是 WMI 的 Win32_NetworkAdapterConfiguration 类有一个属性 IPConnectionMetric ,给无线网络连接实例的这个属性赋予 较高的权重值即可。
http://msdn.microsoft.com/en-us/library/aa394217(v=vs.85).aspx MSDN 中描述的很详细,重要部分摘录如下
Cost of using the configured routes for the IP bound adapter and is the weighted value for those routes in the IP routing table. If there are multiple routes to a destination in the IP routing table, the route with the lowest metric is used. The default value is 1.
Windows 2000: This property is not available. --------- 注意 Win 2000上不能用,没这个属性。
有通过注册表的方法,和通过WMI 脚本两种方法,KB中都描述的很详细,建议有兴趣的朋友自行研究测试。注册表方法比较繁琐,还是脚本方法比较适合企业环境,所以我摘录如下
==== snip - Start of script code Set_Wireless_NIC_IPMetric.vbs script ==== On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") regValueDataMetric = "35" Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapter Where NetConnectionID = 'Wireless Network Connection'") For Each objItem in colItems strMACAddress = objItem.MACAddress Wscript.Echo "MACAddress: " & strMACAddress Next Set colNetCard = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For Each objNetCard in colNetCard If objNetCard.MACAddress = strMACAddress Then For Each strIPAddress in objNetCard.IPAddress Wscript.Echo "Description: " & objNetCard.Description Wscript.Echo "IP Address: " & strIPAddress Wscript.Echo "IPConnectionMetric: " & objNetCard.IPConnectionMetric objNetCard.SetIPConnectionMetric(regValueDataMetric) Next End If Next ==== snip - End of VBS script ====
相关文章推荐
- C:\Windows\system32\MSVCR100.dll 没有被指定在 Windows 上运行,或者它包含错误。请尝试使用原始安装媒体重新安装程序,或联系您的系统管理员或软件供应商以获取支持。【解决办法】
- Ubuntu Grub Rescue 解决Windows分区导致Ubuntu 12.10无法启动的问题以及设定双系统的优先引导顺序
- Broadcom有线网卡在Windows 8/8.1/10下使用系统自带驱动会断网的解决办法
- Windows系统让apache使用其他名称的配置文件修改配置文件名称指定自己的配置文件
- Linux/Windows等系统无线网卡无法使用时利用手机共享网络救急
- python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法
- Windows系统使用vbs脚本或bat脚本强制杀死指定所有进程 vbs实现循环持续写入内容到vbs打开开的记事本 使用vbs、bat添加windows计划任务 使用cmd schtasks命令添加windows计划任务
- python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法
- ubuntu和windows双系统启动顺序的修改
- 【◆◇Windows 7安全模式使用技巧:修复系统故障◆◇】
- Windows系统一台主机供多人同时使用的讨论与软件
- Windows和Ubuntu双系统_Grub调整启动顺序方法
- windows 和 Ubuntu双系统修改启动顺序
- 使用cmd命令批处理判断windows系统是32bit还是64bit
- Windows系统上使用Apache2.2上模块化安装PHP5.3
- windows系统上安装与使用Android NDK r5
- Win10系统更新无线网卡驱动保证无线网正常使用
- windows 系统禁止使用 U 盘的方法
- windows系统 windows7 windows10系统下安装和配置以及使用redis
- windows 无法启动 windows update 服务 (位于本地计算机上) 错误2:系统找不到指定文件