wget usa endereço ipv6 e demora muito para concluir

2

Em um servidor wget-1.16 leva 8 minutos para ser concluído:

$ wget http://http.debian.net/debian/dists/stable/Release -O -
--2017-06-12 23:44:40--  http://http.debian.net/debian/dists/stable/Release         [4693/5569]
Resolving http.debian.net (http.debian.net)... 2001:4f8:1:c::15, 2605:bc80:3010:b00:0:deb:166:202, 2001:610:1908:b000::148:14, ...                                                            
Connecting to http.debian.net (http.debian.net)|2001:4f8:1:c::15|:80... failed: Connection timed out.                 
Connecting to http.debian.net (http.debian.net)|2605:bc80:3010:b00:0:deb:166:202|:80... failed: Connection timed out. 
Connecting to http.debian.net (http.debian.net)|2001:610:1908:b000::148:14|:80... failed: Connection timed out.       
Connecting to http.debian.net (http.debian.net)|140.211.166.202|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://cdn-fastly.deb.debian.org/debian/dists/stable/Release [following]
--2017-06-12 23:51:02--  http://cdn-fastly.deb.debian.org/debian/dists/stable/Release
Resolving cdn-fastly.deb.debian.org (cdn-fastly.deb.debian.org)... 2a04:4e42:3::204, 151.101.12.204                   
Connecting to cdn-fastly.deb.debian.org (cdn-fastly.deb.debian.org)|2a04:4e42:3::204|:80... failed: Connection timed out.
Connecting to cdn-fastly.deb.debian.org (cdn-fastly.deb.debian.org)|151.101.12.204|:80... connected.
...

Porque está tentando se conectar usando o endereço IPv6. curl-7.38.0 na mesma máquina responde instantaneamente. Porque ele usa o endereço IPv4. Eles resolvem o domínio de maneira diferente? Como eles fazem isso? Como posso fazer wget usar o endereço IPv4?

UPD

$ ip a
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d8:cb:8a:37:cf:57 brd ff:ff:ff:ff:ff:ff
    inet 188.40.99.4/26 brd 188.40.99.63 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2a01:4f8:100:738b::2/64 scope global 
       valid_lft forever preferred_lft forever 
    inet6 fe80::dacb:8aff:fe37:cf57/64 scope link                                                     valid_lft forever preferred_lft forever 

$ ip route
default via 188.40.99.1 dev eth0 
10.0.0.0/24 dev br0  proto kernel  scope link  src 10.0.0.1 
188.40.99.0/26 via 188.40.99.1 dev eth0 
188.40.99.0/26 dev eth0  proto kernel  scope link  src 188.40.99.4 
    
por x-yuri 12.06.2017 / 23:20

1 resposta

5

curl e wget não usam mecanismos diferentes para resolver domínios (eles estão usando getaddrinfo() ). No entanto, curl implementa um algoritmo de fallback rápido para melhorar a experiência do usuário em casos em que a conectividade IPv6 é menor do que boa.

Este algoritmo é descrito em detalhes no RFC 6555 (Happy Eyeballs): link

De acordo com curl/lib/connect.h , esse tempo limite é definido como 200 ms: link

As opções curl e wget support -4 / -6 obrigarão a conexão ao IPv4 ou ao IPv6, respectivamente.

    
por 13.06.2017 / 01:21