Configure Linux to prefer IPv6
I know that browsers implement a "fastest wins" connection mechanism (which starts connections on both IPv4 and IPv6, and uses the one that establishes fastest), but things like ping and SSH - I had assumed would default to IPv6 if it was available. Indeed, RFC 3484 specifies the behaviour.
But no.
I can understand it. In the early days, most people didn't have IPv6 connectivity. When a connection was requested, if IPv6 was tried first, at best it would get some sort of ICMP message saying that didn't work, which would cause it to retry with IPv4, causing a delay on each connection. In the worst case, a firewall somewhere would eat the ICMP message, which would cause the v6 connection attempt to time out before retrying with IPv4. Not great for user experience. And it led to people relating enabling IPv6 with network slowness. Even to this day, people still disable it because of this.
In Linux, there is a file called /etc/gai.conf which controls the way getaddrinfo works. And in some distributions, it is configured to ignore IPv6 resolution.
To see how your distribution works, try
ping google.com
or telnet google.com 443
Google advertises both IPv4 and IPv6 addresses, so which your machine tries to connect to will show you your behaviour.
If you have IPv6 connectivity (check with ping -6 google.com), but it defaults to IPv4, you can change this by adding/uncommenting the following in /etc/gai.conf:
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
(I actually had to change fc00::/7 to 1 rather than 6 for some reason - I don't remember why.)
Changes to this file take effect immediately. Once changed, try ping again.
As far as I can tell, there is no downside to enabling this. If my machine doesn't have v6 connectivity, no v6 routes are added, and no v6 connections are attempted.