----- Original Message -----

> On 2014-08-05 at 19:16 -0500, Patrick Landry wrote:
> > I have been experimenting with the sortlist directive in
> > /etc/resolv.conf,

> Ahah, here you go, the normal Linux libc implementation did not carry
> across support for sortlist into getaddrinfo because Ulrich Drepper
> felt that an RFC on an appropriate default standard sorting mechanism
> overrides any locally set administrative policy:

> https://bugzilla.redhat.com/show_bug.cgi?id=144373

Thank you Phil! I am mostly IPv6 ignorant (gotta fix that soon). Your post led 
me on an interesting search this morning and I have come up with an answer. 

RFC 3484 was the original RFC which specified a default address selection 
algorithm for IPv6. It has since been superceded by RFC 6724. 

Modern applications use getaddrinfo (rather than gethostname) and when a 
hostname lookup returns multiple addresses getaddrinfo sorts addresses 
according to the RFC. The default RFC sorting is apparently compiled in. The 
good news is that modern glibc implementations provide a mechanism for system 
administrators to overwrite the defaults via the "/etc/gai.conf file". There 
are several options including one (scopev4) for specifying IPv4 destination 
address sorting preferences. After reading the docs I came up with the 
following /etc/gai.conf file which allowed me to get the destination address 
ordering I desired. 

scopev4 ::ffff:169.254.0.0/112 2 
scopev4 ::ffff:127.0.0.0/104 2 
scopev4 ::ffff:172.20.0.0/120 10 
scopev4 ::ffff:172.20.2.0/120 11 
scopev4 ::ffff:172.20.3.0/120 12 
scopev4 ::ffff:0.0.0.0/96 14 

The first, second and last scopev4 options are the default values used if no 
/etc/gai.conf file exists. The three 172.x.x.x rules result in 172.20.0.0/24 
addresses being ordered before 172.20.2.0/24 addresses which are ordered before 
172.20.3.0/24 addresses. 

According to the glibc documentation since I only include scopev4 options, the 
defaults for the other options will not be affected. 

One other interesting note is that the default sorting prefers IPv6 addresses 
over IPv4 addresses. The main use of the /etc/gai.conf file currently seems to 
be to change that so that IPv4 addressing is preferred. The method to do that 
is mentioned in the Linux glibc documentation and can also be found online. 
http://lmgtfy.com/?q=%2Fetc%2Fgai.conf+prefer+ipv4 

Hopefully this post provides enough information so that the next person who 
goes searching can save some time. 

-- 

patrick 

Patrick Landry 
University of Louisiana at Lafayette 
Director, University Computer Support Services 
_______________________________________________
Tech mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to