How can I set the metric of a manually added route on Windows?

Solution 1:

This question is ancient, but if you stumbled across it like I did, try the following (confirmed on Win10);

open the adapter properties, IPv4 settings, Advanced, then...

Uncheck the "Automatic Metric" as mentioned previously, AND set an interface metric of some value (I used "10" for this example)

Click OK/Apply until you are back at the network connections. Disable and re-enable the adapter to reset everything and incorporate the new setting.

route print... You will now notice the default metric for the adapter has increased by 10 to 20.

add your new default route with a metric of "5" as mentioned previously

route print... it will be created as "15" vs the "20" of the existing default.

Solution 2:

My guess is that it's because of the Automatic Metric option set on the NIC. The automatic metric is based on the link speed so I'm guessing that your host is connected to a 100Mbps switch port. The DG will be assigned a metric based on the link speed alone. Any statically assigned route will be assigned a metric based on the link speed PLUS the metric you assign. If you want to assign a lower metric to your static routing table entry than the metric that's assigned to the DG, then disable the Automatic Metric option on the NIC.

http://support.microsoft.com/kb/299540

Solution 3:

The relevant portion of the route /? help text:

     > route ADD 157.0.0.0 MASK 255.0.0.0 157.55.80.1 METRIC 3 IF 2
              destination^      ^mask     ^gateway     metric^    ^
                                                         Interface^

You can see here that you set this via the METRIC option when you add the route. Lower numbers take priority over higher numbers.

Based on the information you posted, it looks like it is assigning the metric relative to the chart found at this link: http://support.microsoft.com/kb/299540, or relative to the default gateway. You might see if it lets you use a negative value there to force a lower metric cost for your desired route.

Solution 4:

I know this is late but I just ran into this today - I wanted to connect to gmail but it was blocked from the Domain LAN Web Filter. I brought in a wifi usb to get to the non-domain network and was able to get to gmail by changing the priority of the traffic. This still allowed me to access the domain network as well.

To find out the interface #'s

   Route Print 

Use Netsh to set the lower value on the usb wifi device interface. The lower value means higher priority. This will remove the automatic setting as well.

netsh interface ipv4 set interface 25 metric=2

Use Route Print to verify

If you make a mistake you can turn the interface back to automatic

netsh interface ipv4 set interface 25 metric=automatic

For more about netsh see http://www.colorconsole.de/cmd/en/Windows_Vista/netsh/interface/ipv4/set/interface.htm

routing networkingwindowsstatic-route