How do servers/computers/users/applications know to request a resource over the Internet with an IPv6 address vs. and IPv4 address?


The first thing that a client determines is which protocols are available. Let's assume that both IPv4 and IPv6 are available (otherwise the answer to which protocol to choose is trivial ;) It will then do a DNS lookup for both the A (IPv4 address) and AAAA (IPv6 address) records. If only one type is returned then it will use that. If both IPv4 and IPv6 addresses are returned the default behaviour depends a bit on the client software. Usually RFC 3484 is used.

According to the official standards it should prefer IPv6, but because there are some (0.01% or less) machines that have misconfigured IPv6 the clients have become smarter. Most browsers these days will try to connect over IPv6, but if they don't get a working connection within 300 milliseconds they will try to connect over IPv4 in parallel. The first connection that succeeds is then used. This is covered in the Happy Eyeballs RFC.

Apple changed this in Lion. There the operating system actually keeps track of the performance of all connections, and if it determines that the IPv4 connection has lower latency than the IPv6 connection it will start preferring IPv4. But if the IPv4 connection becomes slower it might switch back to IPv6. Take a look at this mailing list thread for a discussion of this feature.

For the user it shouldn't matter if IPv4 or IPv6 is used, as long as it works. IPv4 and IPv6 should be provided equally well. Websites should work exactly the same over IPv4 as over IPv6, etc.

IPv4 will remain is use for many years to come. It will become unusable once new services (websites, games, etc) are deployed only over IPv6 because there are no more new IPv4 addresses to be used. And at some point everything that works over IPv4 will also work over IPv6. At that point in time disabling IPv4 will save time and money (why maintain two protocols when one is enough?).

  • 1
    After this was written, RFC 3484 has been obsoleted by RFC 6724. – Michael Hampton Nov 7 '13 at 4:38
  • How does it determine which protocols are available? I've seen random behavior where apt-get update for example, tries to connect to ipv6 hosts, but the host itself doesn't even have an IPv6 address, aside from its link-local one. – Halfgaar Dec 12 '16 at 9:50
  • 1
    That is handled by source and destination address selection (RFC 6724). In your case it seems like the host sees the AAAA record in DNS, chooses that destination address, then finds out that it doesn't have a source address it can use with that destination, and then falls back to IPv4. – Sander Steffann Dec 12 '16 at 13:08

The intermediate step that's being used now is known as tunneling. Essentially IPv6 packets travel inside IPv4 packets until they reach a point at which they can be stripped of the IPv4 encapsulation and sent out the other side on a full IPv6 network. Of course there's a lot more complexity than that, but the basic concept by-in-large is the same across the board.

As more and more devices become IPv6 capable, and people become more familiar with using the addresses, IPv6 will see increased usage. I don't believe (personal opinion) that IPv6 will truly be embraced and see a large-scale roll-out in the SMB and personal market until IPv4 space becomes an expensive commodity.

At some point in the fairly distant future when IPv6 powers an overwhelming majority of traffic, I could see a reversal of fate for IPv4, where IPv4 traffic must be encapsulated inside regular IPv6 packets and tunnel brokers serve a similar (but reversed) role due to the lack of broad IPv4 routing/IP assignments.

  • 1
    I don't think this answers the question... Besides: Tunneling is quickly disappearing in the core IPv6 internet because native IPv6 is available everywhere now. There will be some tunneling to customers, but that has nothing to do with the choice a system makes when onnecting. PS: IPv4-over-IPv6 tunneling is already appearing. Some cable internet operators are deploying DS-Lite this year, which does exactly that. – Sander Steffann Mar 23 '12 at 6:46
  • I work for a large datacenter and have contacts all of the industry, and my experience is IPv6 is definitely not everywhere now. Tunneling exists to bridge the gap and considering most end-users don't yet have IPv6 assignments, it is still relevant. – Garrett Mar 23 '12 at 15:01
  • 3
    Tunneling is indeed in use, but it should be avoided where possible. ISPs who don't yet offer decent IPv6 to their customers are not doing their job... But anyway: The question was how client applications choose between IPv4 and IPv6, and that has nothing to do with the way the network has its IPv6 connectivity because that is the router's job, not the client application's. The client application just uses whatever is available on the local network. – Sander Steffann Mar 24 '12 at 7:38
  • Crusade on, my friend. – Garrett Mar 25 '12 at 6:09

I think you are asking how an app decides how to choose. From the program side, it depends on application implementation. If the coder makes IPv6 a higher priority than IPv4, for example, it will first try using getipv6addr(). If that is unconfigured or fails, then it will try using getaddr(), etc. Based on this, the app will send the request through IPv6 first, or vice versa.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.