[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#472342: default precedence of 2002::/16 in gai.conf is apparently not what it says



Package: libc6
Version: 2.7-6

Hi,

I have a host with a (global, routable) IPv4 address and a 6to4
(2002::/16) IPv6 address that is derived from it (this is a quite
common setup), and I am trying to connect to another host with the
same setup in the DNS (that is, one A record for an IPv4 address and
one AAAA record for an IPv6 address in 2002::/16, e.g.,
quatramaran.xn--kwg.net is such a host).  I wish to use IPv4
preferentially over 6to4, so I add the following line to /etc/gai.conf

precedence ::ffff:0:0/96  35

(given that the default precedence of 2002::/16 is documented to be
30).  This, however, does not have the desired effect: 6to4 is still
preferred over IPv4 (e.g.: "telnet quatramaran.xn--kwg.net 80" will
try 2002:81c7:8140::1 rather than 129.199.129.64).  However, if I add
the following line:

precedence 2002::/16      30

then the behavior is the desired one.  However the latter line is
supposed to be by default, so adding it should not change the behavior
of getaddrinfo().

Here is an example transcript showing the problem:

orion david ~ $ ip route get 129.199.129.64
129.199.129.64 dev ppp0  src 82.127.104.194 
    cache  mtu 1492 advmss 1452 hoplimit 64
orion david ~ $ ip route get 2002:81c7:8140::1
2002:81c7:8140::1 via ::192.88.99.1 dev tun6to4  src 2002:527f:68c2::3  metric 512  expires 21266585sec mtu 1472 advmss 1412 hoplimit 4294967295
orion david ~ $ egrep '^[^#]' /etc/gai.conf
precedence ::ffff:0:0/96  35
precedence 2002::/16      30
orion david ~ $ host quatramaran.xn--kwg.net
quatramaran.xn--kwg.net has address 129.199.129.64
quatramaran.xn--kwg.net has IPv6 address 2002:81c7:8140::1
orion david ~ $ telnet quatramaran.xn--kwg.net 80
Trying 129.199.129.64...
Connected to quatramaran.xn--kwg.net.
Escape character is '^]'.
^]
telnet> close
Connection closed.
orion david ~ $ echo 'Worked as expected!'
Worked as expected!
orion david ~ $ echo 'But this does not:'
But this does not:
orion david ~ $ sudo perl -pi -e 's/^precedence 2002/\#$&/'
/etc/gai.conf
orion david ~ $ egrep '^[^#]' /etc/gai.conf
precedence ::ffff:0:0/96  35
orion david ~ $ telnet quatramaran.xn--kwg.net 80
Trying 2002:81c7:8140::1...
Connected to quatramaran.xn--kwg.net.
Escape character is '^]'.
^]
telnet> close
Connection closed.

My experiments suggest that precedence of 2002::/16 is effectively at
40, i.e., it is not distinguishing it from ::/0.  I don't understand
why, but whatever the details it's certainly wrong that uncommenting a
line which is supposed to be a default should change anything in what
getaddrinfo() does.

-- 
     David A. Madore
    (david.madore@ens.fr,
     http://www.madore.org/~david/ )



Reply to: