I'm having a little trouble understanding the System.Net.IPAddress
class, because I don't know where to look for a definition of what some of the properties are referring to. Specifically, what are:
IPAddress.IsIPv6LinkLocal
IPAddress.IsIPv6Multicast
I开发者_StackOverflow中文版PAddress.IsIPv6SiteLocal
IPAddress.IsIPv6Teredo
I will also happily accept an answer that points to a resource that explains these concepts. The MSDN site has proved insufficient.
IPAddress.IsIPv6LinkLocal
A link-local address is an IP address that is intended only for communications within the local subnetwork. Routers do not forward packets with link-local addresses.
IPAddress.IsIPv6Multicast
A multicast address is a logical identifier for a group of hosts in a computer network, that are available to process datagrams or frames intended to be multicast for a designated network service. Multicast addressing can be used in the Link Layer (Layer 2 in the OSI model), such as Ethernet multicast, and at the Internet Layer (Layer 3 for OSI) for Internet Protocol Version 4 (IPv4) or Version 6 (IPv6) multicast.
IPAddress.IsIPv6SiteLocal
A unique local address (ULA) is an IPv6 address in the block fc00::/7, defined in RFC 4193. It is the IPv6 counterpart of the IPv4 private address. Unique local addresses are available for use in private networks, e.g. inside a single site or organisation, or spanning a limited number of sites or organisations. They are not routable in the global IPv6 Internet.
IPAddress.IsIPv6Teredo
In computer networking, Teredo is a transition technology that gives full IPv6 connectivity for IPv6-capable hosts which are on the IPv4 Internet but which have no direct native connection to an IPv6 network. Compared to other similar protocols its distinguishing feature is that it is able to perform its function even from behind network address translation (NAT) devices such as home routers.
The answer of CodeNaked is almost correct, but please watch out with IPAddress.IsIPv6SiteLocal. The original IPv6 Site Local addresses (fec0::/10) are deprecated.
These days Unique Local Addresses (ULA) are used in place of Site Local. ULA has two variants: fc00::/8 is not defined yet, but might be used in the future for internal-use addresses that are registered in a central place (ULA Central). fd00::/8 is in use and does not have to registered anywhere. Prefixes from this range are generated randomly.
Unfortunately IsIPv6SiteLocal only checks for the original deprecated version:
PS C:\Users\Administrator> [System.Net.IPAddress]'fec0::'
Address :
AddressFamily : InterNetworkV6
ScopeId : 0
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : True
IPAddressToString : fec0::
It does not recognize ULA Central:
PS C:\Users\Administrator> [System.Net.IPAddress]'fc00::'
Address :
AddressFamily : InterNetworkV6
ScopeId : 0
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
IPAddressToString : fc00::
Or locally assigned ULA:
PS C:\Users\Administrator> [System.Net.IPAddress]'fd00::'
Address :
AddressFamily : InterNetworkV6
ScopeId : 0
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
IPAddressToString : fd00::
Please see https://www.rfc-editor.org/rfc/rfc4193 for further details.
For link local and site local:
http://www.tcpipguide.com/free/t_IPv6SpecialAddressesReservedPrivateLinkLocalSiteLo-3.htm
For link local, site local and multicast (and others as well):
http://technet.microsoft.com/en-us/library/cc757359(WS.10).aspx
For teredo:
http://technet.microsoft.com/en-us/library/bb457011.aspx
HTH
精彩评论