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.
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 aninterface 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 previouslyroute print
... it will be created as "15
" vs the "20
" of the existing default.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
The relevant portion of the
route /?
help text: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.
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
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.
Use
Route Print
to verifyIf you make a mistake you can turn the interface back to automatic
For more about netsh see http://www.colorconsole.de/cmd/en/Windows_Vista/netsh/interface/ipv4/set/interface.htm
routing networkingwindowsstatic-route
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:
This will accomplish your goal reliably. Actually, that's the solution used by the OpenVPN software to establish a default route over a VPN.
route CHANGE 0.0.0.0 MASK 0.0.0.0 192.168.76.1 METRIC 2 IF 11
.route ADD 0.0.0.0 MASK 0.0.0.0 192.168.76.2 METRIC 1 IF 11
.Note: I haven't tested it.