为什么route.exe和WMI / IP帮助程序报告不同的指标?

当我在Windows XP的命令行中调用“route PRINT”时,我得到(?字符是我故意模糊发布的IP地址):

Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.50.1 192.168.50.106 25 0.0.0.0 0.0.0.0 192.168.254.254 192.168.254.64 9999 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 192.168.50.0 255.255.255.0 192.168.50.106 192.168.50.106 25 192.168.50.106 255.255.255.255 127.0.0.1 127.0.0.1 25 192.168.50.255 255.255.255.255 192.168.50.106 192.168.50.106 25 192.168.254.0 255.255.255.0 192.168.254.64 192.168.254.64 9999 192.168.254.64 255.255.255.255 127.0.0.1 127.0.0.1 9999 192.168.254.255 255.255.255.255 192.168.254.64 192.168.254.64 9999 207.???.???.??? 255.255.255.255 192.168.50.1 192.168.50.106 1 207.???.???.??? 255.255.255.255 192.168.50.1 192.168.50.106 1 224.0.0.0 240.0.0.0 192.168.50.106 192.168.50.106 25 224.0.0.0 240.0.0.0 192.168.254.64 192.168.254.64 9999 255.255.255.255 255.255.255.255 192.168.50.106 192.168.50.106 1 255.255.255.255 255.255.255.255 192.168.50.106 10006 1 255.255.255.255 255.255.255.255 192.168.50.106 60003 1 255.255.255.255 255.255.255.255 192.168.254.64 192.168.254.64 1 Default Gateway: 192.168.50.1 

当我打电话

 Get-WmiObject Win32_IP4RouteTable | ft Destination, Mask, NextHop, InterfaceIndex, Metric1, Metric2, Metric3 

从相同的Windows XP机器上的PowerShell我得到以下内容:

 Destination Mask NextHop InterfaceIndex Metric1 Metric2 Metric3 ----------- ---- ------- -------------- ------- ------- ------- 0.0.0.0 0.0.0.0 192.168.50.1 262146 26 -1 -1 0.0.0.0 0.0.0.0 192.168.254.254 65541 1 -1 -1 127.0.0.0 255.0.0.0 127.0.0.1 1 2 -1 -1 192.168.50.0 255.255.255.0 192.168.50.106 262146 26 -1 -1 192.168.50.106 255.255.255.255 127.0.0.1 1 26 -1 -1 192.168.50.255 255.255.255.255 192.168.50.106 262146 26 -1 -1 192.168.254.0 255.255.255.0 192.168.254.64 65541 1 -1 -1 192.168.254.64 255.255.255.255 127.0.0.1 1 10000 -1 -1 192.168.254.255 255.255.255.255 192.168.254.64 65541 1 -1 -1 224.0.0.0 240.0.0.0 192.168.50.106 262146 26 -1 -1 224.0.0.0 240.0.0.0 192.168.254.64 65541 1 -1 -1 255.255.255.255 255.255.255.255 192.168.254.64 65541 1 -1 -1 255.255.255.255 255.255.255.255 192.168.50.106 262146 2 -1 -1 255.255.255.255 255.255.255.255 192.168.50.106 65542 2 -1 -1 255.255.255.255 255.255.255.255 192.168.50.106 393219 2 -1 -1 

192.168.254.64是我的VPN虚拟适配器上的IP地址。 VPN策略当前configuration为使得正常的互联网stream量应该绕过VPN,并且由PRINT路由显示的度量在该上下文中是有意义的。 虚拟接口被分配一个9999的度量,所以stream量将默认为任何其他可用的接口。

但是,WMI返回的路由表显示度量为1.如果我使用IpHelper API调用GetIpForwardTable,则获得与WMI相同的值。 有人碰巧知道为什么这两个表不匹配?

它看起来像route print是“聚合”的指标,而你在PowerShell中做的查询是告诉你到底每一个真正的设置。

换句话说,10000的度量标准实际上只在VPN IP地址的路由条目中设置。 route print显示时,它可能会执行路由查找,并确定到该目标的数据包应该使用VPN接口地址上设置的度量标准。