Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using the following command to add a route, but the metric isn't working the way I want it to. I want the route I am adding to have a lower cost.

    C:\Users\cboyle>route ADD 0.0.0.0 MASK 0.0.0.0  192.168.76.2 METRIC 3 IF 11
 OK!

C:\Users\cboyle>

Here is my routing table before the above command.

    Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\cboyle>route print
===========================================================================
Interface List
 11...00 1a 4d 84 48 22 ......Marvell Yukon 88E8056 PCI-E Gigabit Ethernet Controller
 15...08 00 27 00 40 a3 ......VirtualBox Host-Only Ethernet Adapter
  1...........................Software Loopback Interface 1
 12...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
 13...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0     192.168.76.1    192.168.76.40     20
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
     192.168.56.0    255.255.255.0         On-link      192.168.56.1    276
     192.168.56.1  255.255.255.255         On-link      192.168.56.1    276
   192.168.56.255  255.255.255.255         On-link      192.168.56.1    276
     192.168.76.0    255.255.255.0         On-link     192.168.76.40    276
    192.168.76.40  255.255.255.255         On-link     192.168.76.40    276
   192.168.76.255  255.255.255.255         On-link     192.168.76.40    276
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    306
        224.0.0.0        240.0.0.0         On-link      192.168.56.1    276
        224.0.0.0        240.0.0.0         On-link     192.168.76.40    276
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    306
  255.255.255.255  255.255.255.255         On-link      192.168.56.1    276
  255.255.255.255  255.255.255.255         On-link     192.168.76.40    276
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    306 ::1/128                  On-link
 15    276 fe80::/64                On-link
 15    276 fe80::49e3:31a5:5cc7:97ea/128
                                    On-link
  1    306 ff00::/8                 On-link
 15    276 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

C:\Users\cboyle>

Here it is after.

C:\Users\cboyle>route print
===========================================================================
Interface List
 11...00 1a 4d 84 48 22 ......Marvell Yukon 88E8056 PCI-E Gigabit Ethernet Controller
 15...08 00 27 00 40 a3 ......VirtualBox Host-Only Ethernet Adapter
  1...........................Software Loopback Interface 1
 12...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
 13...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0     192.168.76.1    192.168.76.40     20
          0.0.0.0          0.0.0.0     192.168.76.2    192.168.76.40     23
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
     192.168.56.0    255.255.255.0         On-link      192.168.56.1    276
     192.168.56.1  255.255.255.255         On-link      192.168.56.1    276
   192.168.56.255  255.255.255.255         On-link      192.168.56.1    276
     192.168.76.0    255.255.255.0         On-link     192.168.76.40    276
    192.168.76.40  255.255.255.255         On-link     192.168.76.40    276
   192.168.76.255  255.255.255.255         On-link     192.168.76.40    276
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    306
        224.0.0.0        240.0.0.0         On-link      192.168.56.1    276
        224.0.0.0        240.0.0.0         On-link     192.168.76.40    276
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    306
  255.255.255.255  255.255.255.255         On-link      192.168.56.1    276
  255.255.255.255  255.255.255.255         On-link     192.168.76.40    276
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    306 ::1/128                  On-link
 15    276 fe80::/64                On-link
 15    276 fe80::49e3:31a5:5cc7:97ea/128
                                    On-link
  1    306 ff00::/8                 On-link
 15    276 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

C:\Users\cboyle>

I want the route that I am adding to have priority over the default one.

share|improve this question

3 Answers 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.

share|improve this answer
    
In the command I posted above, I have the METRIC set to 3, but it ended up being 23. Which dose not accomplish my goal. –  Corey Feb 22 '11 at 15:45
    
@Corey did you read my last paragraph? –  Joel Coel Feb 22 '11 at 16:44
1  
just tried a negative value, but it threw an error –  Corey Feb 24 '11 at 4:18
    
Old post but I had to downvote, negative value is useless and while it's true these metrics are being entered relative to the gateway, you don't offer any real advice or solution. –  D3l_Gato Oct 14 at 15:56

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

share|improve this answer
    
I tried disabling "Automatic Metric" on the IP4 settings of the adapter, but still no change in behavior. The command I am using seems to work fine on Windows XP, but not on 7. –  Corey Feb 24 '11 at 4:25
    
Actual useful answer! Thank you. –  D3l_Gato Oct 14 at 15:56

Based on my experience, using several identical routes with different metrics on Windows is tricky at best, and often unreliable, especially on Windows Vista/7. You can work around it by using two routes instead of one, thus forcing Windows to use the more specific routes. So, following your example:

route ADD 0.0.0.0 MASK 128.0.0.0 192.168.76.2 IF 11
route ADD 128.0.0.0 MASK 128.0.0.0 192.168.76.2 IF 11

This will accomplish your goal reliably. Actually, that's the solution used by the OpenVPN software to establish a default route over a VPN.

share|improve this answer
    
Currently it is VPN software that causes troubles for me. It added it's 192.168.*.* routes as a higher priority. Thus having a connected router via LAN you still can not address computers in this LAN. Win7 ROUTE's METRIC parameter completely sucks. –  Askar Kalykov May 22 '13 at 8:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.