How to change the binding order of network adapters in Windows XP and in Windows 2000

Article translations Article translations
Article ID: 894564 - View products that this article applies to.
Expand all | Collapse all

On This Page

SUMMARY

You may have several network connections that are connected to different networks. Or, you may have a program that uses the first connection in the network connections list. You may want to make sure that a certain network connection is at the top of the list.

When you install Microsoft Windows XP or Microsoft Windows 2000, the order of the connections may vary depending on how the network adapters are enumerated.

You can use the methods that are described in this article to reorder adapters and bindings and to change the interface metric on the network adapters. This article describes how to perform the following tasks:
  • Change the binding order of network adapters
  • Change the interface metric on a network adapter
  • Create a fixed metric by changing the InterfaceMetric registry value
  • Set the interface metric by using a script
  • Influence the binding order in Windows XP during unattended setup
  • Change the network provider order

INTRODUCTION

This article describes how to modify the network adapters and the binding order in Microsoft Windows XP and in Microsoft Windows 2000. This article also describes how to change the interface metric on network adapters.

MORE INFORMATION

The following situations are situations in which you may want to change the order of the connections in the list of network adapters and bindings. These situations are also situations in which you might want to change the interface metric on a network adapter.

Note Changing the interface metric on the network adapter gives similar results:
  • The Windows Sockets gethostbyname API is used to retrieve IP addresses that are assigned to a computer. The gethostbyname API returns a list of IP addresses that are assigned to all the network adapters that are installed in the multihomed computer. This list of IP addresses is returned if the host name that is sent in the query is "NULL" or if the host name that is sent by the query is the local host name of the computer.
  • Some third-party device drivers that are installed require that the IP addresses that are returned by the gethostbyname API be listed in a certain order.
  • When a Windows Sockets application calls the gethostbyname API to resolve the local host name to a list of IP addresses on a multihomed computer, the list may be returned in an order that does not match the binding order that is displayed in Control Panel. Or, the list may be returned in an order that does not match the order in which the IP addresses were assigned to the network adapter.
  • You are deploying computers that have a wireless network adapter and a wired network connection. When the computer connects to the wired network, the wireless connection is also enabled. The two connections may cause problems in some programs, and group policies may not work as expected.
Use the methods in this article to resolve or to work around these problems. However, consider the following:
  • There is no unattended way to change the order of the connections during the installation of the network adapter.
  • You cannot programmatically script changes to the binding order of network adapters for a computer that is running.
  • You cannot use Domain Naming System (DNS) to change the order of connections or to change the binding order because DNS does not respect the ordering.
Note This article lists the link speeds and the automatic metrics for computers that run Windows XP and Windows XP Service Pack 2.

How to change the binding order of network adapters

  1. Click Start, click Run, type ncpa.cpl , and then click OK.

    You can see the available connections in the LAN and High-Speed Internet section of the Network Connections window.
  2. On the Advanced menu, click Advanced Settings, and then click the Adapters and Bindings tab.
  3. In the Connections area, select the connection that you want to move higher in the list. Use the arrow buttons to move the connection.

    Notes
    • The Adapters and Bindings tab lists the connections in the order in which the connections are accessed by network services. The order of these connections reflects the order in which TCP/IP or the next available protocol is bound to the network adapters. The bindings for remote access connections apply to all remote access connections.
    • The Provider Order tab lists the network providers for this computer. You can use the arrow buttons to change the order in which these providers are accessed. You can arrange the order in which the computer accesses information about the network. Providers and other connections are accessed in the order in which the providers and the connections are listed.

How to change the interface metric on a network adapter

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
You can change the interface metric on a network adapter if you are using TCP/IP as a transport protocol because TCP/IP uses the interface metric to determine the order. You can change the interface metric to make one network adapter more favorable for all TCP/IP connections. The interface metric (IPConnectionMetric) for a network connection indicates the cost of using the routes in the IP routing table. The routes are derived from the interface configuration. The cost becomes the value in the Metric column for those routes in the IP routing table. If there are multiple routes that are a close match for the route to a destination in the IP routing table, the route that has the lowest metric is used. The range of valid values is 1 through 9999.

To view the IP routing table, type route print at the command prompt. For more information about the Automatic Metric feature that is used in Windows XP for IP routes, click the following article number to view the article in the Microsoft Knowledge Base:
299540 An explanation of the Automatic Metric feature for Internet Protocol routes
To change the interface metric, follow these steps:
  1. Click Start, click Run, type ncpa.cpl , and then click OK.

    The available connections appear in the LAN and High-Speed Internet section of the Network Connections window.
  2. Right-click the network adapter that you want to change, click Properties, and then click the General tab.
  3. In the This connection uses the following items box, select Internet Protocol (TCP/IP). Then, click Properties.
  4. In the Internet Protocol (TCP/IP) Properties dialog box, click the General tab, and then click Advanced.
  5. On the IP Settings tab, click to clear the Automatic metric check box. Then, type a value in the Interface metric box.

    Note In Windows 2000, change the value in the Interface metric box from the default value of 1 to a different value. The Automatic metric check box is not present.

How to create a fixed metric by changing the InterfaceMetric registry value

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
You can create a fixed metric in Windows XP or in Windows 2000 without using the route commands. You can create the fixed metric by changing the following registry key and then restarting the computer. When you create the fixed metric, you can configure a specific network adapter to have the lowest metric so that network adapter is used first.

Note The InterfaceMetric registry value is different for each network adapter.

The InterfaceMetric registry value is located in the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\<GUID>
Configure the registry value as follows:
Name: InterfaceMetric
Type: REG_DWORD
Value Data: A number from 1 to 9999

Determining the NetCfgInstanceId value

In this registry key, GUID is the NetCfgInstanceId value of the network adapter. To determine the NetCfgInstanceId value of the first network adapter, view the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001\NetCfgInstanceId
To determine the NetCfgInstanceId value of the second network adapter, view the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0002\NetCfgInstanceId
The penultimate folder is numbered sequentially for all other network adapters. Or, to view all the network adapters that are installed, locate and then expand the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
See the DriverDesc value to identify the network adapter.

In Windows 2000, the InterfaceMetric registry value does not determine the network adapter that is used first. The network adapter that is selected first also depends on the interface initialization order. The interface initialization order frequently is the same from one startup to the next startup. However, the interface initialization order is not guaranteed to be the same for every startup.

In Windows XP and in Windows 2000, set the metric of the preferred network adapter to be lower than the metrics of the other adapters. Setting the metric lower means that the network adapter has a higher priority. The metric takes precedence in the network adapter order. You can set the metric in the TCP/IP properties.

The following information indicates the settings that you must use to set the metric of the preferred network adapter:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0001\
Name: DriverDesc
Value Data: 3Com 3C920 Integrated Fast Ethernet Controller (3C905C-TX Compatible)

Name: NetCfgInstanceId
Type: REG_SZ
Value Data: {93396AAE-BCC4-49B4-BCDA-27CC97E9D97F}
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{93396AAE-BCC4-49B4-BCDA-27CC97E9D97F}\
Name: InterfaceMetric
Type: REG_DWORD

Sample route metrics and link speeds

Windows XP automatically sets relative route metrics based on link speeds such as the following.
Collapse this tableExpand this table
MetricDescription
10Metric for a connection speed that is more than 200 megabits per second (Mbps)
20Metric for a connection speed that is between 20 Mbps and 200 Mbps
30Metric for a connection speed that is between 4 Mbps and 20 Mbps
40Metric for a connection speed that is between 500 kilobits per second (Kbps) and 4 Mbps
50Metric for a connection speed that is less than or equal to 500 Kbps
For more information and for an updated table that contains the link speeds and the metrics for Windows XP Service Pack 2-based computers, click the following article number to view the article in the Microsoft Knowledge Base:
299540 An explanation of the Automatic Metric feature for Internet Protocol routes
Windows 2000 does not automatically set relative route metrics. Use the following netsh command to verify the current settings of each active interface. To do this, type the following at the command prompt:
netsh interface ip show address
This command creates output that is similar to the following:
Configuration for interface "Local Area Connection"
DHCP enabled: Yes
InterfaceMetric: 0

Configuration for interface "Wireless Connection"
DHCP enabled: Yes
InterfaceMetric: 35
Note An InterfaceMetric value of 0 in the output indicates an automatic metric.

For more information about how to modify the IP connection metric for a network adapter, visit the following Microsoft Web site:
http://www.microsoft.com/technet/scriptcenter/scripts/network/client/modify/nwmovb25.mspx
For more information about Microsoft Windows Management Instrumentation (WMI) tasks for networking, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/aa394595.aspx
For more information about the Win32_NetworkAdapterConfiguration WMI class, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/aa394217.aspx

How to set the interface metric by using a script

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
The following script uses the Win32_NetworkAdapterConfiguration WMI class. This class represents the attributes and the behavior of a network adapter. This class uses the SetIPConnectionMetric method to set the routing metric that is associated with this IP-bound network adapter for a wireless network connection. This method is a new method for Windows XP.

To use the script, copy the following code to a text file, save the file as "Set_Wireless_NIC_IPMetric.vbs," and then run the script.
==== 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 ====

How to influence the binding order in Windows XP during unattended setup

You cannot change the connection order during an unattended setup. There also is no programmatic way to change the binding order of network adapters for a computer that is running. This inability to make a change is a problem if you want to programmatically move one local area connection ahead of another local area connection. However, no documented programmatic method exists for changing the order of the adapters.

The sysprep command removes any networking configuration, and the networking configuration is reconfigured when you run the command. Because the sysprep command writes data to many registry settings and files, the sysprep command is difficult to use to force a change in the binding order.

However, if you want to influence the binding order during unattended setup, you can try to specify one network adapter in the Sysprep.inf file. If you specify the local area network (LAN) adapter and then leave the other adapters to be detected after setup by the Plug and Play feature, Windows may put the LAN adapter at the top of the bindings list. For more information about how to disable network bindings, click the following article number to view the article in the Microsoft Knowledge Base:
263241 How to disable network bindings using the [Netbindings] section

The Bindview sample in the Microsoft Windows Driver Development Kit

The Bindview sample in the Microsoft Windows Driver Development Kit (DDK) demonstrates how to use the INetCfg APIs to bind and to unbind a network adapter. These APIs are documented in the Windows DDK. The Bindview sample is located in the following location:
\WINDDK\build\Src\Network\Config\Bindview
Although binding and unbinding a network adapter is not difficult, moving the network adapter binding is a complex task. No API exists that you can use to move a network adapter binding. However, you can write a stand-alone application to move a network adapter binding by using the INetCfg APIs. To do this, you have to enumerate all the bindings for all the components that are installed on the adapters. Then, you have to move the binding path for each binding so that each binding appears before another binding.

For more information about the INetCfg interface, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/ms805265.aspx
You can enumerate all the adapters, and you can enumerate anything that is bound to each network adapter. Finally, you can use the INetCfgComponentBindings API to unbind the component.

Note Older DDKs such as the Microsoft Windows 2000 DDK and the Windows XP Gold DDK contained the SNetCfg sample that demonstrated these APIs.

Change the network provider order

You can also change the network provider order so that a specific redirector is picked first. These redirectors include server message block (SMB), Web Distributed Authoring and Versioning (WebDAV), and Novell NetWare Client for Windows. The following are the registry subkeys that are related to the redirector.
Collapse this tableExpand this table
RedirectorRegistry subkey
SMBLanmanWorkstation
WebDAVWebClient
Novell NetWare Client for WindowsNetwareRedirector/NetwareWorkstation
You can change the network provider order in Control Panel. For more information, see the "How to change the binding order of network adapters" section. Or, you can change the network provider order by modifying the registry. To change the network provider order by modifying the registry, change the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order
The following settings are the settings that you use to change the provider order:
Name: ProviderOrder
Type: REG_SZ
Value data: LanmanWorkstation,WebClient,RDPNP


The MoveBefore method and the MoveAfter method

You can write a tool in C++ to change the order of the network adapters and the bindings on Windows XP-based client computers. In the tool, use the following:
  • Use the INetCfgComponent API and the INetCfgComponentBindings API from the INetCfg interface.
  • Use the MoveBefore method and the MoveAfter method.
These two methods work as follows:
  • The MoveBefore method sets the order of two binding paths so that one path comes before the other path.
  • The MoveAfter method sets the order of the two binding paths the other way around.
Note These methods are documented in the "Network configuration interfaces" section of the Windows DDK. The "Network configuration interfaces" section of the Windows DDK discusses INetCfg interfaces.

The Bindview sample in the Windows DDK demonstrates how to use the INetCfgComponent API and the INetCfgComponentBindings API. The sample provides code that you can use to change the protocol binding order on a network adapter.

The following pseudo code sorts the bindings correctly. The INetCfg API is the Win32 call that the control program is using. For more information, see the Windows DDK.

Note The INetCfg API is located in the following location:
C:\Winnt\Syste32\Netcfgx.dll
To use the MoveBefore method, follow these steps:
  1. Enumerate the adapters.
  2. Find the Backup Network Connection interface.
  3. Use the MoveBefore method to assign the Backup Network Connection interface as the primary interface.

    Note You can also pass a null value as the second parameter to assign the Backup Network Connection interface as the primary interface.
  4. Find the Primary Network Connection interface.
  5. Use the MoveBefore method to assign the Primary Network Connection interface as the primary interface. Now the Backup Network Connection interface is secondary.

    Note You can also pass a null value as the second parameter to assign the Primary Network Connection interface as the primary interface.
  6. Set the Enable property to False in the INetCfgComponent class to disable the unused network interfaces. Or, use the netsh command.
Pseudo code
INetCfgComponent:Initialize
INetCfg::QueryNetCfgClass( INetCfgClass )
INetCfgClass:: EnumComponents()
Call SetAsPrimary("Backup Network Connection") ' Set Backup network as primary
Call SetAsPrimary("Primary Network Connection") ' Set Primary as primary, now Backup is secondary
INetCfg::Uninitialize
INetCfg::Release

Subroutine SetAsPrimary(Adapter)
For each component ' For each enumerated component
DisplayName = INetCfgComponent::GetDisplayName( INetCfgComponentBindings ) ' Get Adapter display name
If DisplayName = Adapter Then
InetCfgComponentBindings::MoveBefore(INetCfgComponent,Null) ' Move adapter binding to Primary
Exit For Loop
End If
end For
End Sub
For example, if you want to move the binding in which the File and Printer Sharing (FPS) for Microsoft Networks network component is bound to TCP/IP to the top of the bindings for FPS, you have to enumerate the binding paths for FPS. Then, you have to find the binding path for TCP/IP. Call the INetCfgComponentBindings::MoveBefore method for FPS. Use the binding path for TCP/IP as the first parameter of the call, and use a null value in the second parameter.

REFERENCES

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
263241 How to disable network bindings using the [Netbindings] section
299540 An explanation of the Automatic Metric feature for Internet Protocol routes
311272 DevCon command line utility alternative to Device Manager
260937 Some WMI properties and methods are not published in the directory service schema
827536 An IP multicast may not be sent correctly from Windows 2000, Windows XP, or Windows Server 2003
171320 How to change the IP address list order returned
164023 Applications calling gethostbyname() for the local host name may see the list of IP addresses in an order that does not match the binding order
229762 Specifying multiple network adapters in unattended setup
268781 Description of the Netset.exe tool from the Windows 2000 Resource Kit
242468 How to use the Netsh.exe tool and command-line switches
271369 Statically-entered TCP/IP settings are not present after Sysprep
216937 System Preparation tool and Answer File usage
For more information about Microsoft Windows Server 2003 TCP/IP implementation details, visit the following Microsoft Web site:
http://technet2.microsoft.com/WindowsServer/en/library/823ca085-8b46-4870-a83e-8032637a87c81033.mspx?mfr=true
For more information about network configuration interfaces, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/ms805249.aspx
For more information about the INetCfgComponentBindings interface, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/ms805207.aspx
For more information about the INetCfgComponentBindings::MoveBefore method, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/ms805260.aspx

Properties

Article ID: 894564 - Last Review: February 16, 2007 - Revision: 3.6
APPLIES TO
  • Microsoft Windows XP Professional
  • Microsoft Windows XP Professional x64 Edition
  • Microsoft Windows XP Tablet PC Edition
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
Keywords: 
kbhowto kbinfo KB894564

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com