Configuring a Gateway Metric Problem

You want to specify the gateway metric for the default gateway on a Windows Server 2003 computer.


Using a Graphical User Interface

1. Open the Network Connections applet.

2. Double-click on the Local Area Connection icon.

3. Click on Internet Protocol (TCP/IP), and select Properties and then Advanced.

4. In the Default Gateways section, highlight the gateway whose metric you want to modify, and click on Edit. Clear the check mark next to Automatic Metric, and enter a numerical value in the Interface Metric text box.

5. Click OK when you're finished. Using a Command-Line Interface

The following command adds a default gateway of with a metric of 1 to the network connection called Local Area Connection. You can modify the IP address of the gateway, its metric, and the name of the network connection to fit your environment as needed:

> netsh interface ip add address name = "Local Area Connection" gateway = gwmetric = 1

Continuing the example, to change the metric of a gateway that you've already configured, you need to first delete the gateway using the following command:

> netsh interface ip delete address name = "Local Area Connection" gateway =

After that, you can add the gateway again using the new metric.

■Note If you've renamed the network connection from the default of Local Area Connection, you'll need to adjust the previous syntax accordingly.

Using the Registry

To configure the gateway metric, configure the following Registry value:

[HKEY_LOCAL_MACHINE\SYSTEM\Current Control Set\Services\ Tcpip\Parameters\ Interfaces\{<Interface GUID>}] "DefaultGatewayMetric"=REG_MULTI_SZ:"<Metric>"

■Caution If you are configuring metrics for multiple interfaces, you need to list the gateway metrics in the same order that the gateways are listed in the DefaultGateway key.

Using VBScript

This code configures the local interface with a default gateway of and a metric of 1.

strComputer = "."

strGateway = Array("") ' Modify this value as needed strGatewayMetric = Array(1) ' Modify this value as needed ' --------- END CONFIGURATION ------

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set adapters = objWMIService.ExecQuery _

("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each a in adapters errGateways = a.SetGateways(strGateway, strGatewaymetric) If errGateways = 0 Then

WScript.Echo "Success! The default gateway has been set."


WScript.Echo "Error! The default gateway could not be set." End If


How It Works

In TCP/IP, the default gateway associated with an IP address indicates the path through which all non-local traffic should be routed. On a device with only one configured gateway, all traffic will be directed to that one gateway address. If you have a multi-homed computer or a device that has more than one gateway configured, the gateway metric allows the OS to determine which gateway will be used first—a gateway with a metric of 1 will be used before a gateway with a metric of 2, and so forth. To optimize network performance, you should configure the gateway attached to the highest-speed link with the lower gateway metric. This also allows you to create fault tolerance by configuring a secondary gateway attached to a lower-speed link. For example, if the gateway attached to a T-1 line is unavailable, the device can transmit network packets over a gateway attached to a lower-speed ISDN line.

In Windows Server 2003, the gateway metric is configured automatically; the NIC attached to the higher-speed link receives the lower (and therefore preferred) metric. To manually control which gateway receives traffic first, you can configure a gateway metric using any of the methods described in this section.

See Also

• Recipe 1 -3 for more on configuring dead-gateway detection

• Microsoft KB 258487: "Configuring Multiple Adapters on the Same Physical Network"

Was this article helpful?

0 0


    What should my local area connection gateway metric be?
    2 years ago
  • vihtori
    How is the interface metric method configured?
    1 year ago
  • elisha
    What does the gateway metric setting do?
    1 year ago
  • mulu
    Which value will be configured for default gateway of the local area connection?
    11 months ago

Post a comment