当我从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策略当前已配置为使常规Internet流量绕过VPN,并且路由PRINT显示的度量在该上下文中是有意义的。虚拟接口的度量标准为9999,因此流量将默认为任何其他可用接口。
但是,WMI返回的路由表将度量标准显示为1.如果我使用IpHelper API调用GetIpForwardTable,则获得与WMI相同的值。有没有人碰巧知道为什么这两个表不匹配?
答案 0 :(得分:1)
看起来route print
正在“聚合”指标,而您在PowerShell中执行的查询正在告诉您每个人真正设置的内容。
换句话说,10000的度量标准仅在您的VPN IP地址的路由条目上实际设置。当route print
显示它时,它可能会进行路由查找并确定到该目的地的数据包应使用VPN接口地址上设置的度量标准。