How do client applications know to use IPv4 or IPv6?

18

9

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

Bobby S

Posted 2012-03-22T18:24:55.233

Reputation: 341

Answers

25

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?).

Sander Steffann

Posted 2012-03-22T18:24:55.233

Reputation: 4 169

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 – 2016-12-12T09:50:35.317

1That 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 – 2016-12-12T13:08:26.780

1

After this was written, RFC 3484 has been obsoleted by RFC 6724.

– Michael Hampton – 2013-11-07T04:38:22.140

2

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.

Garrett

Posted 2012-03-22T18:24:55.233

Reputation: 4 039

1I 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 – 2012-03-23T06:46:34.457

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 – 2012-03-23T15:01:06.840

3Tunneling 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 – 2012-03-24T07:38:03.543

Crusade on, my friend. – Garrett – 2012-03-25T06:09:20.920

-2

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.

MaryOpen.cn

Posted 2012-03-22T18:24:55.233

Reputation: 1