How to let the browser prefer IPv6 over IPv4?

Solution 1:

It is not the browsers preferring any of the options, it's the operating system. The standard defines the priorities roughly like this:

  1. ipv6
  2. ipv4
  3. 6to4-Traffic

You can change this by editing the label/precedence blocks in /etc/gai.conf (gai stands for getaddrinfo, the standard system call for resolving host names).

A detailed explanation on gai.conf can be found in the man page

This, by the way, also explains Jonathon's experience that the SiXXS tunnel was preferred over 6to4.

Solution 2:

For Firefox & other Mozilla/Gecko-based browsers, the network.dns.disableIPv6 setting in about:config should be false if you have IPv6 (it's set to true by default in Ubuntu, because otherwise lots of people get issues with buggy DNS proxies in home routers).

Solution 3:

As of recent, Chrome, Firefox as well as derived browsers actually avoid IPv6 if a site responds faster over IPv4. It is not possible to change this behavior by means of a configuration setting.

The feature itself is probably reasonable for the common user but it almost drives me mad that you cannot disable it. IPv6 connectivity is pretty good nowadays and sometimes IPv6 has several advantages over connecting through IPv4 even if latency - due to tunneling - is higher. I've been browsing over IPv6 for years and despite IPv6 routing and performance has been getting much better, this damn browser "hack" feature throws me back a decade.

Solution 4:

Just as freddyb pointed out, this depends on the configuration of the standard system call to resolve host names, getaddrinfo.

To solve your problem, replace the content of your /etc/gai.conf with the following lines:

label ::1/128       0
label ::/0          1
label 2002::/16    2
label ::/96         3
label ::ffff:0:0/96 4
label fec0::/10     5
label fc00::/7      6
#label 2001:0::/32   7

updated: thx to freddyb for pointing out that my previous response was wrong: We need to comment the last line, not the 3rd. Now it works for me!

Solution 5:

The answer is simple: Alter the labels.

label 2002::/16    1
label 2001:0::/32   1

This makes them equivalent to "vanilla" ipv6.

If you leave them commented out they'll pick up default values.