Skip to content

Instantly share code, notes, and snippets.

@portablejim
Created January 13, 2012 01:58
Show Gist options
  • Save portablejim/1604220 to your computer and use it in GitHub Desktop.
Save portablejim/1604220 to your computer and use it in GitHub Desktop.
Looking at ipv4 vs ipv6 address selection
# Configuration for getaddrinfo(3).
#
# So far only configuration for the destination address sorting is needed.
# RFC 3484 governs the sorting. But the RFC also says that system
# administrators should be able to overwrite the defaults. This can be
# achieved here.
#
# All lines have an initial identifier specifying the option followed by
# up to two values. Information specified in this file replaces the
# default information. Complete absence of data of one kind causes the
# appropriate default information to be used. The supported commands include:
#
# reload <yes|no>
# If set to yes, each getaddrinfo(3) call will check whether this file
# changed and if necessary reload. This option should not really be
# used. There are possible runtime problems. The default is no.
#
# label <mask> <value>
# Add another rule to the RFC 3484 label table. See section 2.1 in
# RFC 3484. The default is:
#
label ::1/128 0
label fc00::/7 1
label ::/0 2
label ::ffff:0:0/96 3
label 2002::/16 4
label 2001:0::/32 5
label ::/96 10
label fec0::/10 11
#
# This default differs from the tables given in RFC 3484 by handling
# (now obsolete) site-local IPv6 addresses and Unique Local Addresses.
# The reason for this difference is that these addresses are never
# NATed while IPv4 site-local addresses most probably are. Given
# the precedence of IPv6 over IPv4 (see below) on machines having only
# site-local IPv4 and IPv6 addresses a lookup for a global address would
# see the IPv6 be preferred. The result is a long delay because the
# site-local IPv6 addresses cannot be used while the IPv4 address is
# (at least for the foreseeable future) NATed. We also treat Teredo
# tunnels special.
#
# precedence <mask> <value>
# Add another rule to the RFC 3484 precedence table. See section 2.1
# and 10.3 in RFC 3484. The default is:
#
precedence ::1/128 60
precedence fc00::/7 50
precedence ::/0 40
precedence ::ffff:0:0/96 30
precedence 2002::/16 20
precedence 2001::/32 10
precedence ::/96 1
precedence fec0::/10 1
#
# For sites which prefer IPv4 connections change the last line to
#
#precedence ::ffff:0:0/96 100
#
# scopev4 <mask> <value>
# Add another rule to the RFC 3484 scope table for IPv4 addresses.
# By default the scope IDs described in section 3.2 in RFC 3484 are
# used. Changing these defaults should hardly ever be necessary.
# The defaults are equivalent to:
#
#scopev4 ::ffff:169.254.0.0/112 2
#scopev4 ::ffff:127.0.0.0/104 2
#scopev4 ::ffff:0.0.0.0/96 14
#
# For sites which use site-local IPv4 addresses behind NAT there is
# the problem that even if IPv4 addresses are preferred they do not
# have the same scope and are therefore not sorted first. To change
# this use only these rules:
#
#scopev4 ::ffff:169.254.0.0/112 2
#scopev4 ::ffff:127.0.0.0/104 2
#scopev4 ::ffff:0.0.0.0/96 14
Ip addresses are in 2001::/16
dreamplug-debian:~# wget -O /dev/null ipv6.google.com
--2012-01-13 12:49:17-- http://ipv6.google.com/
Resolving ipv6.google.com... 2404:6800:4006:800::1011
Connecting to ipv6.google.com|2404:6800:4006:800::1011|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `/dev/null'
[ <=> ] 12,094 20.5K/s in 0.6s
2012-01-13 12:49:18 (20.5 KB/s) - `/dev/null' saved [12094]
dreamplug-debian:~# wget -O /dev/null www.kame.net
--2012-01-13 12:49:25-- http://www.kame.net/
Resolving www.kame.net... 203.178.141.194, 2001:200:dff:fff1:216:3eff:feb1:44d7
Connecting to www.kame.net|203.178.141.194|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `/dev/null'
[ <=> ] 3,027 --.-K/s in 0.007s
2012-01-13 12:49:26 (415 KB/s) - `/dev/null' saved [3027]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment