本节书摘来自异步社区《深入解析IPv6(第3版)》一书中的第2章,第2.8节,作者: 【美】Joseph Davies 更多章节内容可以访问云栖社区“异步社区”公众号查看。
2.8 使用Windows PowerShell来查看IPv6配置信息
在一台运行Windows Server 2012和Windows 8的计算上,通过Windows PowerShell来查看IPv6配置信息的常用命令如下所示。
- Get-NetIPInterface -AddressFamily IPv6
- Get-NetIPAddress -AddressFamily IPv6
- Get-NetRoute -AddressFamily IPv6
- Get-NetNeighbor -AddressFamily IPv6
如需了解Windows PowerShell中所有可以用来查看TCP/IP配置的命令,可以在Windows PowerShell中运行命令gcm -ModuleNetTCPIP。
2.8.1 Get-NetIPInterface -AddressFamily IPv6
该命令可以显示出IPv6的接口列表,下面是输出信息的示例:
ifIndex ifAlias AddressFamily ConnectionState NlMtu(Bytes)
------- ------- ------------- --------------- ------------
InterfaceMetric Dhcp Store
--------------- ---- -----
20 Reusable ISATAP Interface {... IPv6 Disconnected 0 0
Enabled Persistent
13 isatap.corp.contoso.com IPv6 Disconnected 1280 5
Enabled Persistent
12 Wired Ethernet Connection IPv6 Disconnected 1500 5
Enabled Persistent
10 Local Area Connection* 9 IPv6 Disconnected 0 0
Enabled Persistent
12 Wired Ethernet Connection IPv6 Connected 1500 5
Enabled Active
13 isatap.corp.contoso.com IPv6 Connected 1280 5
Disabled Active
1 Loopback Pseudo-Interface 1 IPv6 Connected 4294967295 50
Disabled Active
2.8.2 Get-NetIPAddress -AddressFamily IPv6
该命令可以显示出各接口的IPv6地址列表,下面是输出信息的示例:
Store : Active
IPAddress : fe80::c51d:624b:b276:6a03%12
InterfaceIndex : 12
InterfaceAlias : Wired Ethernet Connection
AddressFamily : IPv6
Type : Unicast
PrefixLength : 64
PrefixOrigin : WellKnown
SuffixOrigin : Link
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
Store : Active
IPAddress : fe80::5efe:10.198.16.202%13
InterfaceIndex : 13
InterfaceAlias : isatap.corp.contoso.com
AddressFamily : IPv6
Type : Unicast
PrefixLength : 128
PrefixOrigin : WellKnown
SuffixOrigin : Link
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
2.8.3 Get-NetRoute -AddressFamily IPv6
该命令可以显示出IPv6地址路由表中的路由条目列表,下面是输出信息的示例:
ifIndex RouteMetric DestinationPrefix NextHop Store
------- ----------- ----------------- ------- -----
12 256 ff00::/8 :: Active
1 256 ff00::/8 :: Active
12 256 fe80::c51d:624b:b276:6a03/128 :: Active
13 256 fe80::5efe:10.198.16.202/128 :: Active
12 256 fe80::/64 :: Active
13 256 2001:db8:0:fff:0:5efe:10.198.16.202/128 :: Active
13 256 2001:db8:0:fff::/64 :: Active
1 256 ::1/128 :: Active
13 256 ::/0 fe80::5efe:10.36.0.4 Active
2.8.4 Get-NetNeighbor -AddressFamily IPv6
该命令可以显示出接口缓存的内容,该缓存中会保存最新解析出来的下一跳地址的链路层地址(MAC地址),下面是输出信息的示例:
ifIndex IPAddress MacAddress State Store
------- --------- ---------- ----- -----
12 ff02::1:ffe5:a5ed 3333ffe5a5ed Permanent Active
12 ff02::1:ff25:d862 3333ff25d862 Permanent Active
12 ff02::1:3 333300010003 Permanent Active
12 ff02::1:2 333300010002 Permanent Active
12 ff02::2 333300000002 Permanent Active
12 ff02::1 333300000001 Permanent Active
13 fe80::5efe:10.36.0.4 10.36.0.4 Permanent Active