KB299540 explains how Windows XP automatically assign metrics to IP routes:
The following table outlines the criteria that is used to assign metrics for routes that are bound to network interfaces of various speeds.
Greater than 200 Mb: 10 Greater than 20 Mb, and less than or equal to 200 Mb: 20 Greater than 4 Mb, and less than or equal to 20 Mb: 30 Greater than 500 kilobits (Kb), and less than or equal to 4 Mb: 40 Less than or equal to 500 Kb: 50
However, they seem to have changed their algorithm in Windows 7, as my routing table looks like this:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.3 10
0.0.0.0 0.0.0.0 10.202.254.254 10.202.1.2 286
10.202.0.0 255.255.0.0 On-link 10.202.1.2 286
10.202.1.2 255.255.255.255 On-link 10.202.1.2 286
10.202.255.255 255.255.255.255 On-link 10.202.1.2 286
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.0.0 255.255.255.0 On-link 192.168.0.3 266
192.168.0.3 255.255.255.255 On-link 192.168.0.3 266
192.168.0.255 255.255.255.255 On-link 192.168.0.3 266
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.0.3 266
224.0.0.0 240.0.0.0 On-link 10.202.1.2 286
255.255.255.255 255.255.255.255 On-link 10.202.1.2 40
===========================================================================
The only "correct" metric is the first one (Gigabit connection = 10). However, other routes using the Gigabit connection have metric = 266, my VPN has metric = 286, and loopback is 306 (?!).
Any idea what's going on?
I don't think it's new to Windows 7, I think it's there in Vista too.
However, I don't believe there's been a published set of rules that the algorithm follows, just that it's now on a scale of 1-9999.
I don't know the algorithm as well, but you can force a specific metric by changing it on the TCP/IP properties of your network card. On the General tab, click Advanced, uncheck Automatic Metric and set whatever value you like.
I tried this with somewhat a moderated sucess:
Does anyone know hoe to cincurvent any of these problems?
I know this is an old question, but it's one I recently needed the answer to.
I believe the metric you're seeing is actually the
interface metric
+gateway metric
, as noted in one of the answers at https://social.technet.microsoft.com/Forums/windows/en-US/b1fb3e43-300d-49fe-b7a9-be95c7454a82/metric-for-the-default-route?forum=w7itpronetworking . Thus, the calculated metric can be altered by changing which gateway is default or disabling automatic metrics.Automatic metrics can be disabled in the connection's IPv4 properties. Click
Advanced
on theGeneral
tab, uncheck theAutomatic metric
box, and add your own value - such as1
.Myabe the metric has a meaning when the OS is comparing routes from the same protocol? And in that case there should be another metric which is not shown in this table in order to compare the importance of protocols (I mean direct connected, vpn, or other protocols etc)
In general in routing this metric has importance when comparing same protocols. FOr example if OSPF is used metric is taken into account for comparing routes coming from OSPF, but when comparing OSPF route and a directly configured interface, metric has no importance because by default the directly connected will be always preferred.