title: How do you determine equality between two IPv6 addresses?
body: <p>I have an application that allows administrators to specify valid IP addresses from which web service requests can be made.  I simply take the configured IP addresses and compare them against the incoming request.  Comparing two IPv4 addresses is trivial and I thought comparing two IPv6 addresses would be as well.</p>
  
  <p>However, my networking ignorance started to show when I noticed that IPv6 addresses are a little more complex.  One issue I noticed is that if I look at the IP address on the machine (was viewing what VMWare console showed the IP address to be) versus the IP address from the web request (<code>HttpContext.Current.Request.UserHostAddress</code> within .NET) I noticed that one of them ended in %10 and another in %11:</p>
  
  <ul>
  <li>ipconfig shows: fe80:8179:5576:c6d0:8b16%11</li>
  <li>UserHostAddress shows: fe80::8179:5576:c6d0:8b16%10</li>
  </ul>
  
  <p>The only difference is the %10 and %11 - what gives?</p>
  
  <p>I have also seen IPv6 addresses end in "/" followed by 2 digits.  Should I just ignore these final 3 digits (if they exist) when doing a comparison?  If so, what are the valid alternate endings that I need to look for?</p>
  
  <p>----------- EDIT -------------</p>
  
  <p>Here is my solution based on the answer provided...</p>
  
  <p>I simply store a "scrubbed" IP address and compare that with a "scrubbed" IP address.  Using .NET here is how I scrub an IP address.  Not the best from a performance standpoint, but it does work.  I would rather just do a comparison of the <code>GetAddressBytes()</code> but I'm using a <code>Dictionary</code> and I decided against the extra step of creating my own <code>ByteComparer</code>.</p>
  
  <pre><code>IPAddress incomingIp = null;
  bool ipAddressParsePassed = IPAddress.TryParse(userHostAddress, out incomingIp);
  if (ipAddressParsePassed)
  {
      IPAddress scrubbedIp = new IPAddress(incomingIp.GetAddressBytes());
      string scrubbedIpStr = scrubbedIp.ToString()
  }
  </code></pre>