IPv6 and IPv4 Preference

When a site is reachable using both IPv4 and IPv6, Linux by default has a preference which is roughly:

  1. Native IPv6
  2. Native IPv4
  3. 6to4 tunnels

To change this preference, edit ‘/etc/gai.conf’
uncomment most of the labels:

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

(note that 2002::/16 [6to4] is left commented out)

and have the precendence configured as:

precedence  ::1/128       50
precedence  ::/0          40
precedence  2002::/16     30
precedence ::/96          20
precedence ::ffff:0:0/96  10
#
#    For sites which prefer IPv4 connections change the last line to
#
#precedence ::ffff:0:0/96  100

For these changes to have effect, restart the appropriate applications eg. Firefox.