ubuntu – curl和wget尝试ipv6连接

前端之家收集整理的这篇文章主要介绍了ubuntu – curl和wget尝试ipv6连接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的专用服务器(由OVH托管)上,运行全新安装的Ubuntu 14.04,curl和wget大约需要10秒才能完成一个简单的请求.
$curl -v google.com
* Rebuilt URL to: google.com/
* Hostname was NOT found in DNS cache

并且仅在10秒后它才会真正返回一些东西.所以我决定对此进行操作:

write(2,"Hostname was NOT found in DNS ca"...,36) = 36
socket(PF_INET6,SOCK_DGRAM,IPPROTO_IP) = 3
close(3)                                = 0
mmap(NULL,8392704,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK,-1,0) = 0x7f0a24fb8000
mprotect(0x7f0a24fb8000,4096,PROT_NONE) = 0
clone(child_stack=0x7f0a257b7f70,flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,parent_tidptr=0x7f0a257b89d0,tls=0x7f0a257b8700,child_tidptr=0x7f0a257b89d0) = 5047
poll(0,4)                           = 0 (Timeout)
poll(0,8)                           = 0 (Timeout)
poll(0,16)                          = 0 (Timeout)
poll(0,32)                          = 0 (Timeout)
poll(0,64)                          = 0 (Timeout)
poll(0,128)                         = 0 (Timeout)
poll(0,256)                         = 0 (Timeout)
poll(0,1000)                        = 0 (Timeout)
poll(0,1000)                        = 0 (Timeout)

[...] (10 times or so)

poll(0,1000)                        = 0 (Timeout)
socket(PF_INET,SOCK_STREAM,IPPROTO_TCP) = 3
write(2,"*",1)                        = 1
write(2," ","  Trying 74.125.228.7...\n",25) = 25

在所有这些超时之后,我可以清楚地看到套接字(PF_INET6)后跟套接字(PF_INET). wget的行为方式相同.

更多相关信息:

$sudo sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

$sudo cat /etc/default/bind9
RESOLVCONF=yes
OPTIONS="-4 -u bind"

$cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1

ifconfig没有显示inet6地址.

我怎样才能防止这种情况发生?

您可能需要指出IPv4优先于IPv6,如此链接所述. https://askubuntu.com/questions/32298/prefer-a-ipv4-dns-lookups-before-aaaaipv6-lookups

更改/etc/gai.conf下的设置.

原文链接:https://www.f2er.com/ubuntu/348178.html

猜你在找的Ubuntu相关文章