Frozen in Time – aka wanting your OS to prefer IPv4 over IPv6

Recipe for a good geek ‘giggle’

  1. Take any arbitrary Friday
  2. Combine with Neology Dev and Ops staff
  3. Add IPv6
  4. Enjoy the fireworks

Being a rather staunch IPv6 proponent I had to laugh when IPv6 and its ‘issues’ once again saw the light of day on the Neology balcony – but this time the reason was rather valid…. Modern operating systems (read anything built in the past 5 years or so ๐Ÿ˜‰ ) prefers to use IPv6 is its available instead of the venerable sage – IPv4.

In general this is not a bad thing – but when you ask your operating system (lets say debian/windows 7) to look up a specific address it will try to resolve the IPv6 record (AAAA) and the IPv4 (A) record. In many instances this is not a problem as the DNS should respond rather quickly if the AAAA is not available and the A record is then used. This is however not always the case as the underlying DNS resolver may then wait until the AAAA request times out — often measured in seconds. During this time the world essentially stands still.

I’m not going to go into great detail on the specifics of the problem as Wing andย Yourtchenko cover this very nicely in the ‘Happy Eyeballs’ RFC6555. In essence it also describes possible solutions to the problems.

I like and prefer this approach as it pushes towards the adoption of IPv6 – but while we pull developers kicking and screaming from the dark ages (to make use of the Happy Eyeballs approach) another solution is needed:

Enter address precedence, or the order in which local operating system resolvers attempt to find addresses. This allows a local system to be tweaked to prefer specific address classes over others until IPv6 is more adopted.

Microsoft’s approach (http://support.microsoft.com/kb/929852) is to simply prefer IPv4 by changing a registry setting:

Open regedit.exe
Browse to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters \"
Create a DWORD called "DisabledComponents" and set its value to 0x20

The article also contains other possible values of interest.

The Debian/Redhat (read linux in general) way:

Edit /etc/gai.conf as per its examples. But, for the lazy the file should look like this:

precedence  ::1/128        50
precedence  ::/0           40
precedence  2002::/16      30
precedence ::/96           20
precedence ::ffff:0:0/96  100

Let me be clear and say I am not doing either of the above as the systems I try and work on work as I expect ….

Credits to TheRodent, Encrypted and Froztbyte for their heated input on the balcony ๐Ÿ˜‰

Permanent link to this article: https://www.vdvyver.net/frozen-in-time-aka-wanting-your-os-to-prefer-ipv4-over-ipv6/