I am using the .NET Framework
classes to get the IP addresses for my machine.
Dns.GetHostAddresses(Dns.GetHostName())
I have a VirtualBox adapter which has both an IPv4 and IPv6 address. Using the .NET code I am getting the IPv6 address as fe80::71a3:2b00:ddd3:753f%16
Notice the %16 at the end?
However, if I query the same using WMI
, I am getting the address as 'fe80::71a3:2b00:ddd3:753f'
So, does the %16 have any special significance?
Edit:
I just had some more observations about this. And they match pretty well with what Stephen Jennings said in his answer.
I installed Vmware to see what IPv6 address it issued. The addresses were : fe80::3dd0:7f8e:57b7:34d5%19
fe80::b059:65f4:e877:c40%20
Clearly, the numbers after % are not some hex representation. I checked all the properties available for a network adapter using Wmi and found that the numbers are exactly same as the InterfaceIndex property of each network adapter. As per MSDN, it uniquely identifies each network adapter and this property was introduced in Vista.
What still confused me was why would the IPAddress class allow you to create an ip address in that format unless it was valid. The answer was provided by Stephen. The number is the scope id. IPAddress has a constructor that accepts the address AND a scope id.
Oh, and all these three network adapters were link local. Confirmed it via ipconfig
Cool. That was interesting!!
Answer
The number after the '%' is the scope ID.
IPv6 defines at least three reachability scopes for addresses:
Globally addressable. This is an IPv6 address given to you by your ISP. It is available to use on the public Internet.
Link-local. This is similar to the 169.254.X.X range. It is an address that a computer assigns itself in order to facilitate local communications. These addresses don't get routed around on the public Internet because they're not globally unique.
Node-local. This is an address that identifies the local interface, similar to 127.0.0.1. Basically, this is the address ::1.
Microsoft has published this article describing IPv6 addressing, which is the least-confusing article I found. The article indicates that the presence of a scope ID in your address means it is a link-local address. You can also tell it is link-local because the address begins with fe80
.
Clear, simply-understood information on this topic seems to be rare, so I'm putting the rest of this together based on my best understanding of RFC 4007 and the other information out there.
A computer can have multiple link-local addresses, each with a different scope. The scope ID indicates which scope the address is for. For example, imagine the scenario of a computer with two NICs, each with a link-local address on different networks. If you try to send something to another address beginning with fe80, how will the computer know which NIC to send out on? The scope ID appears to be the solution for this.
No comments:
Post a Comment