【问题标题】:PHP cURL IPv6 connect_time very slow on first requestPHP cURL IPv6 connect_time 在第一次请求时非常慢
【发布时间】:2015-04-06 07:16:21
【问题描述】:

我正在尝试制作一个 PHP 脚本,该脚本生成一个随机 IPv6 地址并将其分配给 eth0 并执行一个 HTTP 请求,但似乎所有地址都需要通过首先发出一个虚拟请求来“初始化”。但是,我需要 IP 在创建后的一秒钟内为 HTTP 请求做好准备。经过数小时的测试和互联网搜索,我无法找出问题所在,所以我来到了这里。

我的 Debian VPS 分配了一个 /64 IPv6 地址空间。

为了解释我这样做的问题:

首先我手动分配了 9 个 IP

ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:1 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:2 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:3 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:4 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:5 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:6 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:7 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:8 dev eth0 valid_lft 600 preferred_lft 600                       
ip addr change 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:9 dev eth0 valid_lft 600 preferred_lft 600                       

PHP 脚本:

<?php
$URL = "ipv6.whatismyv6.com";

for($i=1; $i<10; $i++)
{
    $ch = curl_init();

    $IP = "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:{$i}";

    curl_setopt($ch, CURLOPT_URL, $URL);

    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);

    // Set IPv6
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
    curl_setopt($ch, CURLOPT_INTERFACE, $IP);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
    curl_setopt($ch, CURLOPT_TIMEOUT, 120);

    print "IP {$IP}\n";

    curl_exec($ch);

    if(curl_errno($ch))
        die(curl_error($ch));

    var_dump(curl_getinfo($ch));
    print "\nDone for IP {$IP}\n\n";

    curl_close($ch);
}

在第一次运行脚本时,我得到了这个输出。如您所见,除了第一个请求外,每个连接时间都是 32 秒。看起来 cURL 在尝试连接之前需要花费 30 秒的时间。

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:1
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(2.041753)
  ["namelookup_time"]=>
  float(0.969251)
  ["connect_time"]=>
  float(2.002953)
  ["pretransfer_time"]=>
  float(2.002985)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(708)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(2.04171)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:1"
  ["local_port"]=>
  int(46353)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:1

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:2
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(32.02449)
  ["namelookup_time"]=>
  float(3.1E-5)
  ["connect_time"]=>
  float(31.986268)
  ["pretransfer_time"]=>
  float(31.986298)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(45)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(32.024464)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:2"
  ["local_port"]=>
  int(53907)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:2

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:3
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(32.080273)
  ["namelookup_time"]=>
  float(1.9E-5)
  ["connect_time"]=>
  float(32.041328)
  ["pretransfer_time"]=>
  float(32.041358)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(45)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(32.080247)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:3"
  ["local_port"]=>
  int(56910)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:3

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:4
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(32.124284)
  ["namelookup_time"]=>
  float(1.9E-5)
  ["connect_time"]=>
  float(32.085118)
  ["pretransfer_time"]=>
  float(32.085152)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(45)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(32.124239)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:4"
  ["local_port"]=>
  int(59346)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:4

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:5
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(32.074903)
  ["namelookup_time"]=>
  float(1.6E-5)
  ["connect_time"]=>
  float(32.036185)
  ["pretransfer_time"]=>
  float(32.036232)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(45)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(32.074879)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:5"
  ["local_port"]=>
  int(50604)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:5

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:6
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(32.425055)
  ["namelookup_time"]=>
  float(0.35623)
  ["connect_time"]=>
  float(32.386056)
  ["pretransfer_time"]=>
  float(32.386088)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(44)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(32.425031)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:6"
  ["local_port"]=>
  int(35632)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:6

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:7
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(35.150028)
  ["namelookup_time"]=>
  float(2.0E-5)
  ["connect_time"]=>
  float(35.111304)
  ["pretransfer_time"]=>
  float(35.111331)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(41)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(35.149998)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:7"
  ["local_port"]=>
  int(54827)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:7

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:8
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(32.09912)
  ["namelookup_time"]=>
  float(2.0E-5)
  ["connect_time"]=>
  float(32.06125)
  ["pretransfer_time"]=>
  float(32.061287)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(45)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(32.099082)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:8"
  ["local_port"]=>
  int(45077)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:8

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:9
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(32.050919)
  ["namelookup_time"]=>
  float(2.4E-5)
  ["connect_time"]=>
  float(32.011934)
  ["pretransfer_time"]=>
  float(32.01196)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(45)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(32.050894)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:9"
  ["local_port"]=>
  int(48069)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:9

我在第一次运行完成后立即运行脚本,这就是这次的输出。现在 connect_time 一切都很好,我希望它在第一次请求时也是这样。

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:1
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(1.00357)
  ["namelookup_time"]=>
  float(0.93072)
  ["connect_time"]=>
  float(0.966039)
  ["pretransfer_time"]=>
  float(0.966092)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(1440)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(1.003512)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:1"
  ["local_port"]=>
  int(42623)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:1

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:2
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.074783)
  ["namelookup_time"]=>
  float(1.6E-5)
  ["connect_time"]=>
  float(0.035955)
  ["pretransfer_time"]=>
  float(0.035979)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(19335)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.07476)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:2"
  ["local_port"]=>
  int(60928)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:2

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:3
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.076524)
  ["namelookup_time"]=>
  float(2.2E-5)
  ["connect_time"]=>
  float(0.03672)
  ["pretransfer_time"]=>
  float(0.036757)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(18896)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.076497)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:3"
  ["local_port"]=>
  int(37292)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:3

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:4
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.074629)
  ["namelookup_time"]=>
  float(2.1E-5)
  ["connect_time"]=>
  float(0.035955)
  ["pretransfer_time"]=>
  float(0.036001)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(19375)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.074593)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:4"
  ["local_port"]=>
  int(53553)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:4

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:5
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.074592)
  ["namelookup_time"]=>
  float(2.0E-5)
  ["connect_time"]=>
  float(0.036058)
  ["pretransfer_time"]=>
  float(0.036093)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(19385)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.074564)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:5"
  ["local_port"]=>
  int(51041)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:5

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:6
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.074324)
  ["namelookup_time"]=>
  float(1.9E-5)
  ["connect_time"]=>
  float(0.035745)
  ["pretransfer_time"]=>
  float(0.035784)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(19455)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.074282)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:6"
  ["local_port"]=>
  int(37542)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:6

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:7
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.07241)
  ["namelookup_time"]=>
  float(2.3E-5)
  ["connect_time"]=>
  float(0.035187)
  ["pretransfer_time"]=>
  float(0.035246)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(19969)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.072382)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:7"
  ["local_port"]=>
  int(50575)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:7

IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:8
array(27) {
  ["url"]=>
  string(26) "HTTP://ipv6.whatismyv6.com"
  ["content_type"]=>
  string(9) "text/html"
  ["http_code"]=>
  int(200)
  ["header_size"]=>
  int(174)
  ["request_size"]=>
  int(58)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.074898)
  ["namelookup_time"]=>
  float(2.1E-5)
  ["connect_time"]=>
  float(0.036041)
  ["pretransfer_time"]=>
  float(0.036079)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(1446)
  ["speed_download"]=>
  float(19306)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(1446)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.074861)
  ["redirect_time"]=>
  float(0)
  ["certinfo"]=>
  array(0) {
  }
  ["primary_ip"]=>
  string(14) "2001:4810::110"
  ["primary_port"]=>
  int(80)
  ["local_ip"]=>
  string(33) "2001:19f0:xxxx:xxxx:xxxx:xxxx:2:8"
  ["local_port"]=>
  int(58766)
  ["redirect_url"]=>
  string(0) ""
  ["request_header"]=>
  string(58) "GET / HTTP/1.1
Host: ipv6.whatismyv6.com
Accept: */*

"
}

Done for IP 2001:19f0:xxxx:xxxx:xxxx:xxxx:2:8

还有,

wget --bind-address=2001:19f0:xxxx:xxxx:xxxx:xxxx:3:1 http://ipv6.whatismyv6.com

就像 PHP 脚本中的第一个请求一样工作。

我已经为此奋斗了好几天,因此非常感谢任何帮助。

【问题讨论】:

  • 即使地址失效后,我可以将它们添加回来,请求仍然可以正常工作。
  • 数据包捕获会提供一些关于正在发生的事情的提示。
  • @kasperd 我什至没有想到这一点。我花时间用 tcpdump 转储流量,在wireshark 中打开它并截屏。我觉得这表明了问题,但我对网络及其术语知之甚少,无法继续自己解决这个问题。 TCP 握手似乎失败了,因为相邻的东西迟到了 30 秒。但这是我的网络配置或 PHP 的问题吗? i.imgur.com/RUWPL9o.png
  • 前两个数据包已经出现问题。从发送 SYN 开始,在发送邻居请求之前几乎有一秒钟的延迟。邻居请求似乎是由发回 SYN ACK 的需要触发的。但是这个延迟应该只是单次往返,而从 GET 请求和响应中我们可以看到往返实际上不到 40 毫秒。这似乎不是客户端的问题。你能在离服务器更近的地方抓拍吗?
  • 靠近服务器的捕获是什么意思?如果您的意思是目标 HTTP 服务器,它只是我用于测试的启用 IPv6 的随机网站,并且 tcp 转储在所有 IPv6 网站上看起来都差不多。问题可能出在我的服务器提供商方面,所以我应该联系他们吗?

标签: php http curl ipv6


【解决方案1】:

添加 IPv6 地址后,系统通常会进行重复地址检测 (DAD),以确保没有其他系统使用相同的地址。这可能需要几秒钟。如果你确实需要能够立即使用该地址,你需要在界面上禁用 DAD:

echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_dad

【讨论】:

  • 如果这意味着IP地址暂时处于暂定状态,我已经意识到了。不过,这不是这里的问题。我可以等待几分钟,结果仍然是一样的。我认为这是与 PHP 相关的错误/问题。不过,谢谢你,我也想知道该怎么做。
  • 好吧,那确实是别的东西!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-22
  • 2010-10-28
  • 1970-01-01
  • 2013-07-08
  • 2010-12-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多