Thursday, June 30, 2011

How to change the Gateway Metric on Windows 7

If there are multiple physical adapters present in the network, Windows 7 will always look at and compare the indices of gateway metric among the physical adapters and then pick the one with the lowest index to use. In order to override the default settings, you need to adjust the index of gateway metric for each physical adapter. The adapter assigned with the lowest index will always take precedence and used by Windows 7 automatically. For instance, if you want to use the wired connection when both wired and wireless are available in your network. You need to assign the lower gateway metric index to your LAN card so that you can ensure that your favorite adapter will be used by Windows 7 whenever it is available. In my previous post, I mentioned how to use route change command to adjust gateway metric index. In this post, I will present you an easy way to do it without going to the command prompt.

  • Open Network Connection from Network and Sharing Center. Or type ncpa.cpl in the search box at your Windows Explorer or Start menu.
  • Select your favorite connection, e.g., Local Area Connection and then right click to select Properties.
  • In the Networking tab, select the Internet protocol version, e.g., Internet Protocol Version 4 (TCP/IPv4).
  • And then click Properties button.
  • In protocol Properties dialog box, click Advanced....
  • Inside the Advanced TCP/IP Settings, at the IP Settings tab, click Add... of the Default gateways.
  • Uncheck the Automatic metic checkbox, and then enter your router IP (e.g. 192.168.1.1) and assign your metric index. Click Add to insert the entry.

    Default Gateway Settings
  • Click all OK's to exit.

The changes will immediately take effect. If you check your route table after changes (using route print command), you'll find a new entry in the Persistent Routes.

===========================================================================
Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric
          0.0.0.0          0.0.0.0      192.168.1.1      20
===========================================================================

Regardless of the IP address obtained automatically or statically, changing gateway metric can be done via either route change command or network connection GUI (ncpa.cpl).

When you use route print to verify your settings, the metric indices usually will double the number you enter.

Use netsh int ip show config will show the exact settings you will find in the network connection properties.

I hope you'll find this information useful to you.

6 comments:

  1. ow do you determine the Mteric number to put in? You used "20" in your example.
    Also what about setting for TCP/IPv6 ?

    ReplyDelete
  2. what about the network order. anything to do with metric?

    ReplyDelete
  3. How would I automate this specific metric value across many computers without having to change each one? Could a line be added to the AD login script to make the gateway and interface metric value changes arcoss the board without negative side effects? Would there be any trouble from having this line processed and applied to each PC every time the user logs in?

    ReplyDelete
  4. How would I automate this specific metric value across many computers without having to change each one? Could a line be added to the AD login script to make the gateway and interface metric value changes arcoss the board without negative side effects? Would there be any trouble from having this line processed and applied to each PC every time the user logs in?

    ReplyDelete
  5. nice post .
    if i want to restrict specific clients to not goes to gateway 192.168.1.1 .how can i restrict them ?

    ReplyDelete
  6. i have server with ip 10.0.1.1 .my gateway is 10.0.1.243 .after adding gateway it adds default route in routing table .

    i have remote site 10.0.2.0 when i restricting this remote site to connect to my above server i am adding static route add 10.0.2.0 mask 255.255.255.0 10.0.1.233 -p with wrong gateway in my server with lowest metric than default route have .
    but still the server is using the default route .

    ReplyDelete