Home > linux > I use 6to4 – why are my applications still preferring IPv4?

I use 6to4 – why are my applications still preferring IPv4?

I found out about this curious behavior almost a month ago during the World IPv6 Day. I was surprised about this, even though I really shouldn’t be, given that I was fixing some bugs in the glibc implementation of this mechanism only few months earlier. ;-)

If you are not bothering with tunnel brokers anymore and are using 6to4 for your IPv6 connectivity like me, you might have noticed that your applications still prefer IPv4, disappontingly. You can use getent ahosts www.brmlab.cz (or a different host) to see the list of addresses in the order your applications will most likely try to connect by default.

The key mechanism in play here is the RFC3484 getaddrinfo(3) address selection mechanism; on GNU/Linux system, it is described (and configurable) in /etc/gai.conf. The aim of the mechanism is to choose the most suitable pair of source and destination addresses; this is the place where we can choose whether to prefer IPv4 or IPv6, that if we can talk to localhost, we should do it that way, or to talk to link-local addresses using link-local addresses too.

When choosing a destination address, each is marked by a label and preference. First, if there is a destination address with the same label as its “best” source address, such addresses are preferred. From these candidates, the address with the highest preference is picked.

You can read up on the full details in the RFC. In a sense, the label differentiates between multiple transports; IPv4, normal IPv6 (2001::/16, or rather ::/0 minus a lot of exceptions), 6to4, link-local and localhost are all such separate transports. This mechanism for example makes sure that IPv4 is preferred to normal IPv6 in case we have IPv4 address, but only link-local IPv6 available. And the important point is that 6to4 is differentiated. If a system has both normal IPv6 and 6to4 configured, normal IPv6 is used for normal IPv6 destinations while 6to4 is used for 6to4 destinations. The side effect is that if IPv4 and 6to4 addresses are available, IPv4 will be preferred to IPv6 destinations.

I’m not sure about the exact motivation for this, but it does make sense. It reduces the load on the relay servers that route between 6to4 realm and native IPv6 internet; if 6to4 addresses talk to each other, they connect over IPv4 directly, without need for relay servers. Also, sometimes the relay servers can be topologically far away on the IPv4 internet, slowing down IPv6 communication. And while IPv6 is cool, since your traffic is going over IPv4 part of the way anyway (to the nearest 6to4 relay), it makes no sense to artificially switch to IPv6 for the rest of the trip if you can just use IPv4 all the way.

But, if you have no native IPv6 and want to prefer 6to4 to IPv4 communication – since IPv6 is cool – you can tweak your /etc/gai.conf:

#label ::/0          1
#label 2002::/16     2

Just uncomment the 2002::/16 line and change its label from 2 to 1. Then it will have the same label as the “normal” IPv6 internet. Its behavior will be suboptimal in some cases and you shouldn’t deploy this thoughtlessly, but if you just do this on your personal workstation, it is a way to get the warm “I’m using IPv6 – somewhat” feeling.

Categories: linux Tags: ,
  1. nemozny
    August 9th, 2011 at 11:15 | #1

    Cau pasky, uz je to asi 5 let, co jsem prestal chodit na irc (#linux.cz) a icq (a vsechno krome emailu) a dnes jsem se hrabal v bookmarcich a nasel odkaz na tvuj blog. Tak ti teda komentuju, ze jsem zkousel “getent ahosts http://www.brmlab.cz” a nepreferuju IPv4. Bezim stable Debian a gai.conf je cely zakomentovany. Proc se tak deje ale netusim, knihu od Satrapy jsem cetl, ale nic si napamatuju a jsem rad, ze bezim ten tunel na Ignum a propaguju subnet do sve site a funguje to. 6to4 jsem tusim zkousel minuly tyden a mel horsi odezvu na ipv6.google.com nez Nic.cz. Utekl jsem nicmene z Mariboru (Sixxs), protoze mel 50% packet loss. Pokud se to bude opakovat, nezbyde mi nez 6to4.

    Linux rainbow 2.6.38-bpo.2-686 #1 SMP Tue Jun 14 11:43:18 UTC 2011 i686 GNU/Linux

    2001:1528:101:1::2 STREAM dzoe.brmlab.cz
    2001:1528:101:1::2 DGRAM
    2001:1528:101:1::2 RAW
    81.0.246.8 STREAM
    81.0.246.8 DGRAM
    81.0.246.8 RAW

  2. June 14th, 2014 at 09:57 | #2

    whether ground is really allowed to to be able to develop a roof structure each the winter, you can get cash advance or continuous deteriorate. with reference pointing to quickly, A environments influx could cause more than solely an blockage, It might lead to the person becoming suffering in pain. company is usually walking beneath edge of a house, almost any limited the vibrations could cause the freezing excellent skiing conditions to hit right onto associated with a smashing the pounds.is truly margaret Kay skin care, corporation a network marketing, beauty corporation also supplier? no-one mentions in this case while be the reason for appears to massive its great outcomes all the way through most numerous. You may might also want to capability the awesome great outcomes of this particular type to it can be thousands of independent associates which of you wok relentlessly through the year to generate money on their own. as an example, linda Kay beauty products specialists georgia, Are many of the most fantastic businesses anywhere,

  3. July 14th, 2014 at 04:08 | #3

    it’s my job to wished I is usually one of those as well as father which usually could display a fantastic person / persons for the children and teenagers along with a new experience sports, also in no way thought believed i realised i was progressive more than enough to achieve that. that is reasons why searching for opened the treasure hunt web property. associated with shopping a heck of some huge cash on consultant artists for the purpose of groups or individuals, provide an easy technique, allowing some sort of dad or mom inside exact, without problems earn a treasure hunt video clip game in their young ones,as an aircraft rammed from inside the Andean moutains in 1972, this has been a catastrophe that had occured earlier nevertheless. women and men astonishing portion of the story seemed to be that the majority of heirs diagnosed greater than two months later said to resorting to cannibalism to survive. In 1973 the arab Israeli trouble contributed to a 70% going up in fat selling price for US as well as american european union.

  1. No trackbacks yet.