Matthias Kuehn <[EMAIL PROTECTED]> writes: > it seems wget sorts the v4/v6 ip´s before creating a table of the > returned ip´s.
Wget does really do that. It does prefer IPv4 addresses to IPv6 addresses, and it caches the addresses resolved (but only during a single Wget run), but it doesn't sort the addresses of the same address family, it leaves them in the order returned by the resolver. > try e.g. > wget http://db.de.clamav.net/ $ wget http://db.de.clamav.net/ -d ... Resolving db.de.clamav.net... 212.162.12.159, 62.26.160.3, 62.75.188.79, ... Caching db.de.clamav.net => 212.162.12.159 62.26.160.3 62.75.188.79 194.77.146.139 85.25.252.58 85.214.44.186 89.149.194.18 193.239.17.68 195.246.234.199 213.9.78.42 213.209.100.191 217.115.136.166 217.160.141.39 Connecting to db.de.clamav.net|212.162.12.159|:80... connected. ... $ wget http://db.de.clamav.net/ -d ... Resolving db.de.clamav.net... 212.162.12.159, 62.26.160.3, 62.75.188.79, ... Caching db.de.clamav.net => 212.162.12.159 62.26.160.3 62.75.188.79 194.77.146.139 217.160.141.39 85.25.252.58 85.214.44.186 89.149.194.18 193.239.17.68 195.246.234.199 213.9.78.42 213.209.100.191 217.115.136.166 Connecting to db.de.clamav.net|212.162.12.159|:80... connected. $ wget http://db.de.clamav.net/ -d -O/dev/null ... Resolving db.de.clamav.net... 212.162.12.159, 62.26.160.3, 62.75.188.79, ... Caching db.de.clamav.net => 212.162.12.159 62.26.160.3 62.75.188.79 194.77.146.139 85.25.252.58 85.214.44.186 89.149.194.18 193.239.17.68 195.246.234.199 213.9.78.42 213.209.100.191 217.115.136.166 217.160.141.39 Connecting to db.de.clamav.net|212.162.12.159|:80... connected. ... As you can see, the order cached (and used) is not the same across several Wget runs, but the first several addresses returned by the resolver are. > compiling with ipv6 disabled seems to work on v4, and no sorting is > done. randomizing (as suggested on the mailing-list) is no good > idea, because wget still has a different result from what the > resolver returned. If it works without IPv6, then it means that getaddrinfo on your machine sorts the results, whereas gethostbyname doesn't. The only sorting Wget does is "sorting" by address family (which is a stable sort that preserves the order of addresses within an address family), and that one is disabled using --prefer-family=none.